预期的浏览器二进制位置,但无法在默认位置找到二进制文件,没有使用 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.
任何想法 - 高度赞赏!
Any thoughts-highly appreciated!
推荐答案
此错误信息...
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 FilesMozilla Firefoxfirefox.exe'
driver = webdriver.Firefox(executable_path=r'C:WebDriversgeckodriver.exe', 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屋!