selenium3.0.1调用firefox

您所在的位置:网站首页 locationno selenium3.0.1调用firefox

selenium3.0.1调用firefox

2024-07-13 07:02| 来源: 网络整理| 查看: 265

报错信息如下时:

selenium.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的安装路径,直接增加到 python35\Lib\site-packages\selenium\webdriver\firefox 目录下的 firefox_binary.py文件中,如下图所示,然后driver = webdriver.Firefox()调用



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3