预期的浏览器二进制位置,但无法在默认位置找到二进制,没有使用GeckoDriver提供的'moz:firefoxOptions.binary'功能 [英] Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided using GeckoDriver

查看:504
本文介绍了预期的浏览器二进制位置,但无法在默认位置找到二进制,没有使用GeckoDriver提供的'moz:firefoxOptions.binary'功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

from selenium import webdriver;
browser= webdriver.Firefox();
browser.get('http://www.seleniumhq.org');

当我尝试运行此代码时,它给我一个错误消息:

When I try to run this code, it gives me an error 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.

任何想法-高度赞赏!

推荐答案

此错误消息...

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.

...表示 GeckoDriver在默认位置找不到 Firefox 二进制文件.此外,您还没有通过 moz:firefoxOptions.binary 功能.

...implies that the GeckoDriver was unable to find the Firefox binary at the default location. Additionally you haven't passed the moz:firefoxOptions.binary capability.

可能在您的系统中自定义位置,在这些情况下,您需要通过 moz:firefoxOptions.binary 功能传递 Firefox 二进制文件的绝对路径,如下所示:

Possibly within your system firefox is installed in a custom location and these cases you need to pass the absolute path of the Firefox binary through the moz:firefoxOptions.binary capability as follows:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
driver = webdriver.Firefox(executable_path=r'C:\WebDrivers\geckodriver.exe', firefox_options=options)
driver.get('http://google.com/')


参考文献

您可以在以下位置找到几个相关的详细讨论:


References

You can find a couple of relevant detailed discussion in:

这篇关于预期的浏览器二进制位置,但无法在默认位置找到二进制,没有使用GeckoDriver提供的'moz:firefoxOptions.binary'功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆