Search code examples
pythonseleniumsendkeys

Web automation error in python while running..i m using selenium


I just started web automation and I can't figure out this error.. Code-

from selenium import webdriver

site = webdriver.Chrome()
site.get('https://www.youtube.com')
searchbar = site.find_element_by_xpath('//*[@id="search"]')
searchbar.click()
searchbar.send_keys('Fireproof')

searchButton = site.find_element_by_xpath('//*[@id="search-icon-legacy"]')
searchButton.click()

Error in cmd-

Its opening the browser but not doing anything after that


Solution

  • Issue is with XPath, user below code having updated XPath.

    searchbar = driver.find_element_by_xpath('//input[@id="search"]')
    searchButton = driver.find_element_by_xpath('//button[@id="search-icon-legacy"]')