【问题标题】:MSEdgeDriver - session not created: No matching capabilities found error on Selenium with PythonMSEdgeDriver - 会话未创建:使用 Python 在 Selenium 上找不到匹配功能错误
【发布时间】:2021-06-03 08:35:27
【问题描述】:

让我们的自动化在 Microsoft Edge 上运行时遇到了一些问题。安装了正确的浏览器版本驱动程序并尝试了其他一些“修复”无济于事。这是在 PyCharm 上使用 Selenium 和 Python3。

回到开头,这是我的代码……

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.edge.options import Options
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

options = Options()
driver = webdriver.Edge(executable_path='/Users/james.stott/PycharmProjects/venv/Selenium/Remote/msedgedriver')

以下是引发的错误...

selenium.common.exceptions.SessionNotCreatedException:消息:未创建会话:未找到匹配的功能

任何帮助,将不胜感激。

【问题讨论】:

    标签: python selenium automation microsoft-edge selenium-edgedriver


    【解决方案1】:

    我猜你正在使用 Edge Chromium,你可以参考以下步骤使用 Selenium python 代码自动化 Edge 浏览器:

    1. 从此link 下载并安装 Python。

    2. 管理员身份启动命令提示符。

    3. 运行以下命令安装 Edge Selenium 工具。

      pip install msedge-selenium-tools selenium==3.141
      
    4. 从此link 安装正确版本的 Edge Web 驱动程序。 (WebDriver版本应与Edge浏览器版本一致)

    5. 使用下面的代码创建一个 Python 文件,并根据自己的要求进行修改。

      from msedge.selenium_tools import Edge, EdgeOptions
      
      options = EdgeOptions()
      options.use_chromium = True
      options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
      driver = Edge(executable_path = r"D:\selenium web drivers\edge driver\msedgedriver.exe", options = options) # Modify the path here...
      driver.get("https://example.com")
      

    更新:

    如果您使用的是 Mac OS,则需要发送功能。你可以尝试发送一个空的能力:

    desired_cap={}
    
    driver = webdriver.Edge(executable_path='/Users/james.stott/PycharmProjects/venv/Selenium/Remote/msedgedriver', capabilities=desired_cap)
    

    【讨论】:

    • 发生同样的错误。未找到匹配的功能
    • 您使用的是哪个版本的 Edge 浏览器和 Edge WebDriver?
    • Microsoft Edge 版本 89.0.774.50(官方版本)(64 位)EdgeDriver Release 89 版本:89.0.774.50
    • 您使用的是 Mac OS 吗?如果是这样,您需要发送功能。可以参考this thread。我也编辑了我的答案,你可以检查一下。
    • 这已经奏效了。感谢您对此的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 2017-02-23
    相关资源
    最近更新 更多