为了账号安全,请及时绑定邮箱和手机立即绑定

尝试使用 selenium 运行脚本时出现错误

尝试使用 selenium 运行脚本时出现错误

慕姐8265434 2021-09-14 15:28:18
每当我尝试运行此代码时from selenium import webdriverfrom selenium.webdriver.common.keys import Keysimport timebrowser = webdriver.Chrome()browser.get("https://kahoot.it/") time.sleep(10)code = browser.find_element_by_id("inputSession")code.send_keys("273976")login_attempt = browser.find_element_by_xpath("//*[@type='submit']")login_attempt.submit()我收到错误Traceback (most recent call last):File "C:\Users\jiney\AppData\Local\Programs\Python\Python37- 32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in startstdin=PIPE)File "C:\Users\jiney\AppData\Local\Programs\Python\Python37- 32\lib\subprocess.py", line 756, in __init__restore_signals, start_new_session)File "C:\Users\jiney\AppData\Local\Programs\Python\Python37- 32\lib\subprocess.py", line 1155, in _execute_childstartupinfo)FileNotFoundError: [WinError 2] The system cannot find the file specifiedDuring handling of the above exception, another exception occurred:Traceback (most recent call last):File "C:/Users/jiney/AppData/Local/Programs/Python/Python37- 32/kahootthing.py", line 4, in <module>browser = webdriver.Chrome()File "C:\Users\jiney\AppData\Local\Programs\Python\Python37-32\lib\site- packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__self.service.start()File "C:\Users\jiney\AppData\Local\Programs\Python\Python37-32\lib\site- packages\selenium\webdriver\common\service.py", line 83, in startos.path.basename(self.path), self.start_error_message)selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home如果有任何帮助,将不胜感激,因为它非常令人困惑,我认为这与模块有关,但我已尝试卸载并重新安装两次。
查看完整描述

2 回答

?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

您必须安装ChromeDriver并使其在路径中可用。


查看完整回答
反对 回复 2021-09-14
  • 2 回答
  • 0 关注
  • 200 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信