python2.x 使用selenium时,报错Message: 'geckodriver' executable needs to be in PATH.

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhen_6137/article/details/82414429
from selenium import webdriver
#from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('http://www.baidu.com')
search = browser.find_element_by_class_name('s_ipt')
search.send_keys('kafka')
sumbit_btn = browser.find_element_by_id('su')
sumbit_btn.submit()

报错:selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

如果你的selenium是3.X版本的,火狐浏览器需要geckodriver这个组件的支持,而谷歌浏览器需要chromedriver的支持,2.X版本则不需要。

在执行webdriver.Firefox()时 会报Message: 'geckodriver' executable needs to be in PATH.

解决办法:

https://github.com/mozilla/geckodriver/releases 下载 自己操作系统相应版本的geckodriver,我的系统是windows 10 - x64位

所以我下载的是geckodriver-v0.21.0-win64.zip ,解压 将geckodriver.exe 放至Python安装的根目录即可。

参考:https://www.cnblogs.com/lvzuwen/p/7309341.html

https://blog.csdn.net/skyplay520/article/details/73810794

https://blog.csdn.net/qq_35444750/article/details/79619964

扫描二维码关注公众号,回复: 4546794 查看本文章

https://jingyan.baidu.com/article/c910274b87b84acd361d2da3.html

猜你喜欢

转载自blog.csdn.net/zhen_6137/article/details/82414429
今日推荐