最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中Selenium报错:SessionNotCreatedException Expected browser binary location moz:firefoxOptions.binary

Mac crifan 1168浏览 0评论
折腾:
【未解决】Selenium中用js新建窗口再切换窗口
期间,代码:
from selenium import webdriver

fox = webdriver.Firefox()
报错:
发生异常: SessionNotCreatedException
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
File "/Users/crifan/dev/dev_root/python/seleniumJsNewWindow/seleniumJsNewWindow.py", line 7, in <module> fox = webdriver.Firefox()
Driver requirements :: Documentation for Selenium
SessionNotCreatedException Expected browser binary location moz:firefoxOptions.binary
python – Expected browser binary location, but unable to find binary in default location, no ‘moz:firefoxOptions.binary’ capability provided using GeckoDriver – Stack Overflow
看来是:当前Mac中,没有安装Firefox浏览器软件本身
而只是安装了Firefox的driver:geckodriver
Firefox was not installed on my system at all. That’s why this error came up.
和我猜的一样。
所以去:
Mac中安装Firefox浏览器
firefox mac
下载适用于 Mac 的 Mozilla Firefox — 快速、私密且免费 – Mozilla 出品
Firefox 90.0.dmg
然后再去执行代码,即可正常运行,打开Firefox了:
【总结】
此处代码:
from selenium import webdriver

fox = webdriver.Firefox()
报错:
发生异常: SessionNotCreatedException
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=Firefox的程序
解决办法:
(此处Mac中去)安装Firefox
步骤:去官网下载
下载适用于 Mac 的 Mozilla Firefox — 快速、私密且免费 – Mozilla 出品
得到:Firefox 90.0.dmg
双击,根据提示,拖动FireFox到 应用程序中,即可。

转载请注明:在路上 » 【已解决】Mac中Selenium报错:SessionNotCreatedException Expected browser binary location moz:firefoxOptions.binary

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.183 seconds, using 23.39MB memory