ConnectionResetError:[WinError 10054]使用Selenium Chrome时

时间:2016-11-23 15:48:52

标签: python-3.x google-chrome selenium

您好我的代码突然出现了一个简单的问题,直到昨天它正常工作,这意味着它打开了一个网页并输入了登录详细信息(是对更大的应用程序的测试),但现在每当它尝试连接到登录页面我收到超时错误。我已将Selenium和Chrome网络驱动程序更新到最新版本,但仍然无法连接,这是我的代码:

#importing libraries, selenium is the base of the script, time to add pauses when appropiate or necessary and select and request will stay until i determine that they are not necessary for the final script.
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
import requests
#defining browser to use the webdriver with chrome, and navigating to Makor.
browser = webdriver.Chrome()
browser.get('http://mrmprod/Login.aspx')

这是完整的错误代码:

  

追踪(最近一次通话):         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ Scripts \ Input   test.py",第7行,in           browser = webdriver.Chrome()         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ chrome \ webdriver.py",   第69行,在 init 中           desired_capabilities = desired_capabilities)         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py",   第92行,在 init 中           self.start_session(desired_capabilities,browser_profile)         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py",   第179行,在start_session中           response = self.execute(Command.NEW_SESSION,capabilities)         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py",   第234行,执行中           response = self.command_executor.execute(driver_command,params)         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ remote_connection.py",407行,执行           return self._request(command_info [0],url,body = data)         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ site-packages \ selenium \ webdriver \ remote \ remote_connection.py",第439行,在_request           resp = self._conn.getresponse()         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ http \ client.py",   第1197行,在getresponse中           response.begin()         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ http \ client.py",   第297行,开头           版本,状态,原因= self._read_status()         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ http \ client.py",   第258行,在_read_status中           line = str(self.fp.readline(_MAXLINE + 1)," iso-8859-1")         文件" C:\ Users \ AMSUser \ AppData \ Local \ Programs \ Python \ Python35-32 \ lib \ socket.py",   第575行,在readinto           return self._sock.recv_into(b)       ConnectionResetError:[WinError 10054]远程主机强制关闭现有连接

我问网络管理员,他告诉我网络设置没有任何变化,因为我原来的代码工作正常。

1 个答案:

答案 0 :(得分:0)

如果您已阅读上述内容,请执行以下步骤:

您必须在括号内包含chromedriver路径。

检查以下代码:

用于Windows OS的代码示例

browser = webdriver.Chrome('C:\\User\\YOUR_USERS_NAME\\YOUR_PATH\\chromedriver.exe')

用于LINUX操作系统的代码示例

browser = webdriver.Chrome('usr\\bin\\YOUR_PATH\\chromedriver')

希望我能帮助您!