2

运行驱动程序时出现以下错误 Edge opens 但随后弹出此错误并且无法运行其余代码

我的代码

from selenium import webdriver

driver = webdriver.Edge()
driver.get("https://stackoverflow.com")

Traceback (most recent call last):
  File "C:\Users\Jawad Azhar Ch\Documents\1.CODING\idm dload\id.py", line 4, in <module>
    driver = webdriver.Edge()
  File "C:\Users\Jawad Azhar Ch\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 61, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\Jawad Azhar Ch\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\Jawad Azhar Ch\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Jawad Azhar Ch\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Jawad Azhar Ch\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Unknown error
4

2 回答 2

1

根据使用 WebDriver (Chromium) 进行测试自动化以使用WebDriver启动 Microsoft Edge (Chromium)浏览上下文中的文档,您需要执行以下步骤:

边缘版本.png

边缘驱动安装.png


示范

您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    
    driver = webdriver.Edge(executable_path=r'C:\WebDrivers\msedgedriver.exe')
    driver.get('edge://settings/help')
    print("Page title is: %s" %(driver.title))
    
  • 控制台输出:

    Page title is: Settings
    
  • 浏览器快照:

微软边缘

于 2020-07-20T17:48:13.710 回答
0

我认为您没有导入其他问题中所需的所有内容,请参阅: https ://www.browserstack.com/guide/launch-edge-browser-in-selenium

于 2020-07-20T17:33:49.977 回答