【发布时间】:2018-06-10 23:01:53
【问题描述】:
我是 selenium 库的新手,请帮助我解决此错误以使用 selenium 启动 firefox 会话。
这是我目前的代码
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# create a new Firefox session
driver = webdriver.Firefox()
发生的错误是
Traceback(最近一次调用最后一次):文件 "C:\Users\yash\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", 第 74 行,在 start stdout=self.log_file, stderr=self.log_file) 文件中 "C:\Users\yash\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", 第 707 行,在 __init__restore_signals, start_new_session) 文件中 "C:\Users\yash\AppData\Local\Programs\Python\Python36-2\lib\subprocess.py", 第 990 行,在 _execute_child 启动信息中)FileNotFoundError:[WinError 2] 系统找不到指定的文件
在处理上述异常的过程中,又发生了一个异常:
Traceback(最近一次调用最后一次):文件 “A:\python\webscraping\seltry.py”,第 5 行,在驱动程序 = webdriver.Firefox() 文件 "C:\Users\yash\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", 第 148 行,在 init self.service.start() 文件中 "C:\Users\yash\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", 第 81 行,在 start os.path.basename(self.path) 中, self.start_error_message) selenium.common.exceptions.WebDriverException:消息:'geckodriver' 可执行文件需要在 PATH 中。
请帮忙!
【问题讨论】:
标签: python-3.x selenium firefox webautomation