TA的每日心情 | 无聊 2024-9-19 09:07 |
---|
签到天数: 11 天 连续签到: 2 天 [LV.3]测试连长
|
刚接触python,写自动化脚本启动firefox浏览器时一直报错。代码如下:
- #coding=utf-8
- from selenium import webdriver
- driver = webdriver.Firefox()
- driver.get("http://www.baidu.com")
- driver.find_element_by_id("kw").send_keys("Selenium2")
- driver.find_element_by_id("su").click()
- driver.quit()
复制代码
报错
Traceback (most recent call last):
File "C:\Users\zzh19\Desktop\python\baidu.py", line 3, in <module>
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
到网上找了一下原因,可能是没有gecko driver驱动,就下载了驱动放到浏览器目录下,path环境变量也改了,但是还是没有用怎么办,求助。。。。
|
|