【问题标题】:selenium.common.exceptions.WebDriverException: Message: Unknown error while trying to use Edge and MicrosoftWebDriver.exe through Seleniumselenium.common.exceptions.WebDriverException:消息:尝试通过 Selenium 使用 Edge 和 MicrosoftWebDriver.exe 时出现未知错误
【发布时间】:2019-03-18 11:20:41
【问题描述】:

我用 Python 创建了一个脚本,该脚本废弃了 Altium 的网站并收集了有关许可证使用情况的信息。目前,我正在使用 ChromeDriver,但由于网络在一天中的不同时间很慢,有时会出现错误。我在个人计算机上使用 MicrosoftWebDriver (Edge) 使用了相同的脚本,但没有收到任何错误。当你启动 MicrosoftWebDriver.exe(从他们的网站下载)时,它应该会打开 Edge,但是当我使用我公司的笔记本电脑时,什么也没有发生(见附图)。

我有机会解决这个问题吗?这是由于端口被阻塞造成的吗?

这是我用于选择网络驱动程序的代码:

browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')

这是我得到的“错误”:

在这之后什么都没有发生......

Python 的 Shell 是这样说的:

Traceback (most recent call last):
  File "C:\ALTIUM_WORK\Altium_Python\Altium_H1.py", line 172, in <module>
    browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
  File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 66, in __init__
    desired_capabilities=capabilities)
  File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Program Files (x86)\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Unknown error

【问题讨论】:

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


    【解决方案1】:

    你需要传递参数executable_path如下:

    browser = webdriver.Edge(executable_path=r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
    

    【讨论】:

      【解决方案2】:

      这解决了问题...

      本地安全策略 -> 本地策略 -> 安全选项 -> 用户帐户控制:在管理员批准模式下运行所有​​管理员 -> 启用

      【讨论】:

        【解决方案3】:
        browser = webdriver.Edge(r'C:\ALTIUM_WORK\Altium_Python\MicrosoftWebDriver.exe')
        

        这不起作用,因为在您的办公室笔记本电脑中User Account Control settingsTurned Off

        您需要打开User Account Control settings 并重新启动您的机器,然后运行您的代码。它将按预期工作。

        转到操作系统上的路径:

        Control Panel-->All Control Panel Items-->User Accounts--> Change User Account Control settings
        

        【讨论】:

          猜你喜欢
          • 2019-06-16
          • 2020-10-16
          • 2021-05-22
          • 1970-01-01
          • 2018-08-18
          • 1970-01-01
          • 2019-02-27
          • 2019-02-01
          相关资源
          最近更新 更多