折腾:
【未解决】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()

SessionNotCreatedException Expected browser binary location moz:firefoxOptions.binary
看来是:当前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


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
步骤:去官网下载
得到:Firefox 90.0.dmg
双击,根据提示,拖动FireFox到 应用程序中,即可。
转载请注明:在路上 » 【已解决】Mac中Selenium报错:SessionNotCreatedException Expected browser binary location moz:firefoxOptions.binary