selenium.common.exceptions.SessionNotCreatedException:消息:无法通过Selenium找到与Firefox 46匹配的功能集 [英] selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities with Firefox 46 through Selenium

查看:111
本文介绍了selenium.common.exceptions.SessionNotCreatedException:消息:无法通过Selenium找到与Firefox 46匹配的功能集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里必须有一些版本不匹配,因为我无法使用Python来获取Selenium来启动Firefox Web浏览器.我使用的是旧版本的Firefox,因为此处的其他人使用的是相同的旧版本的Python,而对于他们来说,旧版本的Firefox效果最佳.

I must have some versions here that don't match up since I can't get Selenium with Python to fire up a Firefox web browser. I'm using an older version of Firefox because other people in here have the same old version of Python and for them the old version of Firefox works best.

代码:

from selenium import webdriver
from selenium import common
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver=webdriver.Firefox(capabilities=DesiredCapabilities.FIREFOX)

错误:

Traceback (most recent call last):
  File "scrapeCommunitySelenium.py", line 13, in <module>
    driver=webdriver.Firefox(capabilities=DesiredCapabilities.FIREFOX)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 158, in __init__
    keep_alive=True)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute
    self.error_handler.check_response(response)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

版本信息:

  • Python 2.7.10
  • 硒3.8.0
  • Firefox 46.0
  • GeckoDriver 0.19.1(位于我的PATH环境变量中的文件夹中)
  • MacOS 10.12.6

推荐答案

在使用 Selenium 3.8.0 时,必须强制使用 GeckoDriver .但是再次使用Firefox v46.0 时,您必须将功能牵线木偶设置为FalseDesiredCapabilities(),如下所示:

As you are using Selenium 3.8.0 you have to use GeckoDriver as a mandatory. But again as you are using Firefox v46.0 you have to set the capability marionette as False through DesiredCapabilities() as follows :

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False
browser = webdriver.Firefox(capabilities=cap, executable_path="C:\\path\\to\\geckodriver.exe")
browser.get('http://google.com/')
browser.quit()

这篇关于selenium.common.exceptions.SessionNotCreatedException:消息:无法通过Selenium找到与Firefox 46匹配的功能集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆