我正在使用此代码使用默认配置文件设置打开边缘:
from msedge.selenium_tools import Edge, EdgeOptions
edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("user-data-dir=C:\\Users\\PopA2\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default")
edge_options.add_argument("profile-directory=Profile 1")
edge_options.binary_location = r"C:\\Users\\PopA2\\Downloads\\edgedriver_win64 (1)\\msedgedriver.exe"
driver = Edge(options = edge_options, executable_path = "C:\\Users\\PopA2\\Downloads\\edgedriver_win64 (1)\\msedgedriver.exe")
driver.get('https://google.com')
driver.quit()
但我收到此错误:
PS C:\Users\PopA2> & "C:/Program Files/Python37/python.exe" "c:/Users/PopA2/OneDrive/Desktop/test de pe net.py" Traceback(最近一次调用最后):文件“c:/Users/PopA2/OneDrive Group/Desktop/test de pe net.py”,第 13 行,在驱动程序 = Edge(options = edge_options,executable_path = "C:\Users\PopA2\Downloads\edgedriver_win64 (1)\ msedgedriver.exe”)文件“C:\Program Files\Python37\lib\site-packages\msedge\selenium_tools\webdriver.py”,第 108 行,在init desired_capabilities=desired_capabilities)文件“C:\Program Files\Python37\lib \site-packages\selenium\webdriver\remote\webdriver.py",第 157 行,在init self.start_session(capabilities, browser_profile) 文件“C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 252 行,在 start_session 响应 = self.execute(Command.NEW_SESSION,参数)文件“C:\Program Files\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第 321 行,执行 self.error_handler.check_response(response) 文件“C:\Program Files\ Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py",第 242 行,在 check_response 中引发 exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: MSEdge failed to start : 被杀害。(未知错误:DevToolsActivePort 文件不存在)(进程从 msedge 位置 C 开始: