无法用selenium-python-geckodriver打开firefox

问题描述:

Newbee在这里!帮帮忙!无法用selenium-python-geckodriver打开firefox

环境:的Windows 10.1(64位)+硒+的Python + geckodriver.exe(最新版本 - v0.13.0 - https://github.com/mozilla/geckodriver/releases

问题:

  • 无法打开火狐使用以下

代码中提到的代码浏览器中使用:

from selenium import webdriver 
path = 'C:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\firefox\geckodriver.exe' 
browser = webdriver.Firefox(path) 
browser.get("https://www.google.com/") 

注:

  • 能够使用chromewebdriver & Microsoftwebdriver通过改变位置路径打开浏览器IE &相应边缘
  • 设置好的Windows环境路径环境了。检查下面:
    • C:\ Program Files文件(x86)的\ Python36-32 \ LIB \站点包\硒\ webdriver的
    • C:\ Program Files文件(x86)的\ Python36-32
    • C: \程序文件(x86)\ Python36-32 \脚本

问题:

  1. 什么是问题?给出正确的位置路径。仍然无法打开
  2. 上面的环境变量中设置的路径是否正确?我试过多次改变它,但没有用。有人可以分享你的工作环境变量路径吗?

请回复!谢谢你的时间!

+0

分享你的错误回溯 – Andersson

请尝试以下,让我知道它是否解决您的问题或不

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 
from selenium import webdriver 

path = 'C:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\firefox\geckodriver.exe' 
binary = FirefoxBinary('C:\Path\to\firefox.exe') # Set your own path 
browser = webdriver.Firefox(path, firefox_binary=binary) 

以下值添加到PATH:

  1. C:\ Program Files文件(x86)的\ Python36-32 \ LIB \站点包\硒\ webdriver的\火狐(即,直到geckodriver.exe)

当寻找在PATH文件/ EXE文件,也不会看这条道路的子文件夹内。

或者

保持geckodriver。exe文件在下面的路径,这是已经加入到PATH之一:

  1. C:\程序文件(x86)\ Python36-32 \脚本
  2. C:\程序文件(x86)\ Python36-32
  3. C:\ Program Files文件(x86)的\ Python36-32 \ LIB \站点包\硒\ webdriver的

注:系统重新启动可能是必要的。