在Win10内部版本16299和硒3.14.1上,以下代码(@@@@ =已编辑)
from selenium import webdriver
dir = '/Users/@@@@/AppData/Local/Continuum/anaconda3/Library/bin'
edge_driver_bin = 'MicrosoftWebDriver.exe'
edge_file = f'{dir}/{edge_driver_bin}'
driver = webdriver.Edge(edge_file)
用空白页打开Edge并引发以下异常:
WebDriverException Traceback (most recent call last)
<ipython-input-2-106cfded919a> in <module>
6 edge_file = f'{dir}/{edge_driver_bin}'
7 print(edge_file)
----> 8 driver = webdriver.Edge()
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\edge\webdriver.py in __init__(self, executable_path, capabilities, port, verbose, service_log_path, log_path, keep_alive)
64 resolve_ip=False,
65 keep_alive=keep_alive),
---> 66 desired_capabilities=capabilities)
67 self._is_remote = False
68
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
155 warnings.warn("Please use FirefoxOptions to set browser profile",
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
159 self._mobile = Mobile(self)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile)
250 parameters = {"capabilities": w3c_caps,
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
254 response = response['value']
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))
~\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
206 if exception_class == ErrorInResponseException:
207 raise exception_class(response, value)
--> 208 raise exception_class(value)
209 if message == "" and 'message' in value:
210 message = value['message']
WebDriverException: Message: Unknown error
由于相关的堆栈溢出过帐而添加了edge_file代码,但没有区别。网络驱动程序在路径中。
该代码适用于chrome;我想使用edge以便使测试环境与我的编码环境分开。它可以在Jupyter中与Chrome和REPL一起使用。
应该没什么区别,但是Edge的代码正在Jupyter中运行。
没有模式对话框。 (也在单独的堆栈溢出发布中提到)