运行python时出现Web自动化错误..我正在使用selenium

2024-04-27 03:29:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚启动了web自动化,但我无法找出这个错误。。 代码-

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-

它打开浏览器,但之后什么也不做


Tags: 代码fromwebidsearchby错误site
1条回答
网友
1楼 · 发布于 2024-04-27 03:29:44

问题在于XPath,下面的用户代码已经更新了XPath

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

相关问题 更多 >