python+selenium打不开浏览器,求教
from selenium import webdriverdriver=webdriver.Firefox()
url='http://www.baidu.com'
driver.get(url)
driver.close()
各位大神,不是说firefox的driver是自带的吗。报错提示如下:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files\Python36\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python36\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Program Files/Python36/test.py", line 3, in <module>
driver=webdriver.Firefox()
File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in __init__
self.service.start()
File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
补充一下,geckodriver已经下载了,放在firefox的目录下了。firefox的环境变量也配了。 火狐版本高 查一下版本对应的文本driver 你的火狐浏览器和selenium版本是多少,看下是不是不兼容导致的 python2.7+selenium2.0+firefox32.0
有大神告诉我这样搭配比较好,我也是弄了好几天,最后换了个低版本的chrome就行了 学习 应该就是浏览器驱动和版本不匹配造成的,建议使用firefox 35版本以下的 把geckodriver放到C:\Program Files\Python36\Scripts下可以解决了。谢谢各位大神解答。
页:
[1]