序号未找到 - MicrosoftDriver.exe

时间:2017-10-17 15:07:44

标签: python selenium automation microsoft-edge

我正在尝试使用边缘浏览网址。我已下载最新的MicrosoftWebDriver并放在Downloads文件夹中。

我的代码:

import os 
from selenium import webdriver    
dir = "C:\Users\Local_Admin\Downloads" 
edge_path = dir + "\MicrosoftWebDriver.exe" 
driver = webdriver.Edge(edge_path) 
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("https://www.freelancer.in/")
driver.quit()

我总是在下面收到控制台错误,弹出窗口说" Ordinal Not Found - MicrosoftDriver.exe":

Traceback (most recent call last):
File "test_edge.py", line 7, in <module>
driver = webdriver.Edge(edge_path)
File "C:\Python27\lib\site-packages\selenium-3.4.3-py2.7.egg\selenium\webdriver\edge\webdriver.py", line 34, in __init__
self.edge_service.start()
File "C:\Python27\lib\site-packages\selenium-3.4.3-py2.7.egg\selenium\webdriver\common\service.py", line 102, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)

selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:\Program Files (x86)\Microsoft Web Driver\MicrosoftWebDriver.exe

1 个答案:

答案 0 :(得分:0)

this GitHub conversation,问题可能与网络配置有关。

127.0.0.1 localhost添加到计算机的hosts文件可能会解决问题。