【问题标题】:Unable to find a matching set of capabilities with selenium 3.4.3, firefox 54.0 and gecko driver 0.17无法找到与 selenium 3.4.3、firefox 54.0 和 gecko 驱动程序 0.17 匹配的一组功能
【发布时间】:2017-11-19 22:22:30
【问题描述】:
if __name__ == '__main__':
driver=webdriver.Firefox(executable_path=r'/home/saurabh/Saurabh/LearnPython/Automation/geckodriver');
运行上面的代码后,我得到一个错误:
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities
【问题讨论】:
标签:
selenium
firefox
selenium-webdriver
webdriver
geckodriver
【解决方案1】:
我没有在您的代码中看到任何重大错误。
需要注意的是,当前的 Selenium-Python 绑定对于 geckodriver 来说是不稳定的,并且看起来是特定于体系结构的。你可以在这里找到 github discussion 和 merge。因此,在初始化 webdriver
时,您可能还需要将 firefox 二进制文件的绝对路径作为 firefox_binary 参数传递
这是您自己的代码,只需稍加调整即可打开 Mozilla Firefox 浏览器:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
if __name__ == '__main__':
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\\path\\to\\geckodriver.exe")
【解决方案2】:
确保您指向\path\to\FirefoxPortable\App\Firefox64\firefox.exe 而不仅仅是\path\to\FirefoxPortable\FirefoxPortable.exe