预期的浏览器二进制位置,但无法在默认位置找到二进制,没有使用GeckoDriver提供的'moz:firefoxOptions.binary'功能 [英] Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided using GeckoDriver
问题描述
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.
可能在您的系统中firefox 自定义位置,在这些情况下,您需要通过 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:
- SessionNotCreatedException:消息:预期的浏览器二进制位置,但无法在默认位置找到二进制文件,没有'moz:firefoxOptions.binary'
- InvalidArgumentException:消息:二进制不是使用GeckoDriver Firefox Selenium和Python的Firefox可执行错误
- 预期浏览器的二进制位置,但无法在默认位置找到二进制,因此未提供"moz:firefoxOptions.binary"功能
这篇关于预期的浏览器二进制位置,但无法在默认位置找到二进制,没有使用GeckoDriver提供的'moz:firefoxOptions.binary'功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!