MSEdgeDriver-未创建会话:在Selify和Python上未发现匹配功能错误 [英] MSEdgeDriver - session not created: No matching capabilities found error on Selenium with Python

查看:22
本文介绍了MSEdgeDriver-未创建会话:在Selify和Python上未发现匹配功能错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Microsoft Edge上运行自动化时遇到一些问题。安装了正确的浏览器版本驱动程序,并尝试了其他几个修复程序,但都无济于事。这是在PyCharm上使用Selence和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:消息:未创建会话:未找到匹配的功能

如有任何帮助,我们将不胜感激。

推荐答案

我猜您使用的是Edge Chromium,您可以参考下面的步骤,使用Selify Python代码自动执行Edge浏览器:

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

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

  3. 运行下面的命令以安装Edge Selify工具。

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

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

    from msedge.selenium_tools import Edge, EdgeOptions
    
    options = EdgeOptions()
    options.use_chromium = True
    options.binary_location = r"C:Program Files (x86)MicrosoftEdgeApplicationmsedge.exe"
    driver = Edge(executable_path = r"D:selenium web driversedge drivermsedgedriver.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)

这篇关于MSEdgeDriver-未创建会话:在Selify和Python上未发现匹配功能错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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