当前位置:首页>开发>正文

selenium对应的火狐浏览器驱动安装 web自动化中selenium 3.X 使用火狐的那个版本

2023-07-31 04:34:49 互联网 未知 开发

 selenium对应的火狐浏览器驱动安装 web自动化中selenium 3.X 使用火狐的那个版本

selenium对应的火狐浏览器驱动安装

1. Firefox 48 以上版本selenium 3.x Firefox驱动(geckodriver)驱动下载地址传智播客官网2. Firefox 48 以下版本selenium 2.x 内置驱动如果想了解更多可以来传智播客咨询一下

web自动化中selenium 3.X 使用火狐的那个版本

web 自动化中 如果selenium 是3.X 版本 通常要使用firefox 48以上的版本
selenium 3.x Firefox驱动(geckodriver)
驱动下载的地址 http://www.seleniumhq.org/download/
如果 Firefox 48 一下的版本
selenium 2.X 内置驱动
如果想了解更多 其他浏览器和selenium版本兼容问题可以到黑马程序员官网询问。

seleniu3.0怎么调用firefox

lenium.common.exceptions.WebDriverException: Message: geckodriver executable needs to be in PATH.
这是因为在Firefox高版本需要使用 geckodriver 来驱动,不再使用Seleniu默认自带的Firefox webdriver。
我们只需要在下面这个地址下载 geckodriver 并将 其所在的路径设为环境变量即可解决。
https://github.com/mozilla/geckodriver/releases
当报如下错误信息时,则是
selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location,
no moz:firefoxOptions.binary capability provided, and no binary flag set on the command line
这时我们需要指定Firefox浏览器程序路径。
binary = FirefoxBinary(D:\Firefox\Firefox\firefox.exe)
driver = webdriver.Firefox(firefox_binary=binary)
注:提示找不到"firefoxBinary"可以通过下面语句导入 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
这样就能正常使用了。

另一个处理办法是将firefox的安装路径,直接增加到 python35Libsite-packagesseleniumwebdriverfirefox 目录下的 firefox_binary.py文件中,如下图所示,然后driver = webdriver.Firefox()调用

最新文章