简体   繁体   English

urlopen错误[Errno 111]连接拒绝了selenium python

[英]urlopen error [Errno 111] Connection refused for selenium python

When I try to log out from the testing page, there occurs an connection refused error. 当我尝试从测试页面注销时,会出现连接拒绝错误。 This is the command / code I've used: 这是我用过的命令/代码:

driver.find_element_by_xpath("//a[@href = '/logged/pages/user/logout.php']").click()

I also tried by linktext, or ActionChains, the same error. 我也尝试过linktext或ActionChains,同样的错误。 And it happens sometime, not always, Any comments? 它发生在某个时间,而不是总是,任何评论?

The Error Message: 错误消息:

<urlopen error [Errno 111] Connection refused>
Stacktrace

Traceback (most recent call last):
  File "/home/jenkins/run/workspace/QA_DEV_CINDY_LOGGED/LoggedSmoke/LoggedCommonFunction.py", line 158, in Logout
    link.click()
  File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/remote/webelement.py", line 70, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/remote/webelement.py", line 404, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/remote/webdriver.py", line 193, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/remote/remote_connection.py", line 358, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.3/site-packages/selenium/webdriver/remote/remote_connection.py", line 426, in _request
    resp = opener.open(request)
  File "/usr/local/lib/python3.3/urllib/request.py", line 469, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.3/urllib/request.py", line 487, in _open
    '_open', req)
  File "/usr/local/lib/python3.3/urllib/request.py", line 447, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.3/urllib/request.py", line 1274, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/local/lib/python3.3/urllib/request.py", line 1253, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.3/http/client.py", line 1147, in getresponse
    response.begin()
  File "/usr/local/lib/python3.3/http/client.py", line 358, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.3/http/client.py", line 328, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.3/urllib/request.py", line 1248, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/local/lib/python3.3/http/client.py", line 1065, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/lib/python3.3/http/client.py", line 1103, in _send_request
    self.endheaders(body)
  File "/usr/local/lib/python3.3/http/client.py", line 1061, in endheaders
    self._send_output(message_body)
  File "/usr/local/lib/python3.3/http/client.py", line 906, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.3/http/client.py", line 844, in send
    self.connect()
  File "/usr/local/lib/python3.3/http/client.py", line 822, in connect
    self.timeout, self.source_address)
  File "/usr/local/lib/python3.3/socket.py", line 435, in create_connection
    raise err
  File "/usr/local/lib/python3.3/socket.py", line 426, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused 

This is a temporary connectivity issue between your Selenium language bindings and a Selenium server . 这是Selenium语言绑定和Selenium服务器之间临时连接问题 This may happen more often if you are using a remote Selenium server on a different machine and especially if it goes over the internet. 如果您在不同的计算机上使用远程Selenium服务器,特别是如果它通过Internet,则可能会更频繁地发生这种情况。 We've, for instance, seen this kind of errors when using remote selenium servers at BrowserStack or Sauce Labs. 例如,我们在BrowserStack或Sauce Labs使用远程selenium服务器时看到了这种错误。

Since Python/Selenium bindings don't have an automatic way to retry JSON wire (JSON over HTTP) requests/commands, you are forced to handle it in your code. 由于Python / Selenium绑定没有自动重试JSON wire(JSON over HTTP)请求/命令的方法,因此您必须在代码中处理它。 For instance, if these are tests you are executing - a common way to tackle these errors is to retry failed tests 3 times and, only if all 3 attempts fail - report a failed test. 例如,如果这些是您正在执行的测试 - 解决这些错误的常用方法是重试失败的测试3次,并且仅当所有3次尝试都失败时 - 报告测试失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium - urllib.error.URLError: <urlopen error [Errno 61] Connection refused> - Selenium - urllib.error.URLError: <urlopen error [Errno 61] Connection refused> Mysql([Errno 111] 连接被拒绝)”) - Mysql ([Errno 111] Connection refused)") Ftplib ConnectionRefusedError: [Errno 111] 连接被拒绝 (python 3.5) - Ftplib ConnectionRefusedError: [Errno 111] Connection refused (python 3.5) python-valve rcon minecraft&#39;ConnectionRefusedError:[Errno 111]连接被拒绝&#39; - python-valve rcon minecraft 'ConnectionRefusedError: [Errno 111] Connection refused' Errno111 连接被拒绝 Kivy 套接字错误 - Errno111 Connection Refused Kivy Socket Error Python 套接字收到错误“连接被拒绝错误 111” - Python socket getting the error “connection refused error 111” 尽管外壳程序脚本引发[Errno 111]连接被拒绝,但在Docker启动时使用TCP Server执行python3脚本 - Executing a python3 script with TCP Server on Docker startup though shell script throws [Errno 111] Connection refused 在Python(多处理)中正确酸洗和取消代理对象? “ConnectionRefusedError:[Errno 111] 解压时连接被拒绝” - Properly pickling and unpickling proxy objects in Python (multiprocessing)? "ConnectionRefusedError: [Errno 111] Connection refused while unpickling" 在连接到Heroku上的mongoDB时出现错误:“ localhost:27017:[Errno 111]连接被拒绝”,但在我的计算机上工作正常 - Getting error: “localhost:27017: [Errno 111] Connection refused” while connecting to mongoDB on Heroku but works fine on my computer Docker。 无法建立新连接:[Errno 111] Connection refused' - Docker. Failed to establish a new connection: [Errno 111] Connection refused'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM