微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Selenium-Python:是否可以通过增加WebDriverWait.poll_frequency来防止MaxRetryError?

如何解决Selenium-Python:是否可以通过增加WebDriverWait.poll_frequency来防止MaxRetryError?

现在,我了解到这是跨站点一个常见问题,但在以下所述的情况下,将在实例化poll_frequency类帮助时设置webdriverwait吗?

在特定的GUI上进行回归时,在整个测试版本中,我在随机的情况下遇到异常Max retries exceeded with url: /session/46cb728d61ec7389a9b40b225692ebfb/element (Caused by NewConnectionError(\'<urllib3.connection.httpconnection object at 0x7fe92676cef0>: Failed to establish a new connection: [Errno 111] Connection refused\'。像这样将轮询频率增加到1后,我已经对其进行了多次测试,并且它没有出现任何问题(只是稍微放慢了脚本的速度),但是我可以确定它将解决最大重试异常,如下所示:>

in until\n value = method(self._driver)\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/expected_conditions.py",line 64,in __call__\n return _find_element(driver,self.locator)\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/expected_conditions.py",line 411,in _find_element\n return driver.find_element(*by)\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py",line 978,in find_element\n \'value\': value})[\'value\']\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py",line 319,in execute\n response = self.command_executor.execute(driver_command,params)\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py",line 374,in execute\n return self._request(command_info[0],url,body=data)\n File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py",line 397,in _request\n resp = self._conn.request(method,body=body,headers=headers)\n File "/usr/local/lib/python3.6/dist-packages/urllib3/request.py",line 80,in request\n method,fields=fields,headers=headers,**urlopen_kw\n File "/usr/local/lib/python3.6/dist-packages/urllib3/request.py",line 171,in request_encode_body\n return self.urlopen(method,**extra_kw)\n File "/usr/local/lib/python3.6/dist-packages/urllib3/poolmanager.py",line 336,in urlopen\n response = conn.urlopen(method,u.request_uri,**kw)\n File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py",line 767,in urlopen\n **response_kw\n File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py",line 727,in urlopen\n method,error=e,_pool=self,_stacktrace=sys.exc_info()[2]\n File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py",line 439,in increment\n raise MaxRetryError(_pool,error or ResponseError(cause))\nurllib3.exceptions.MaxRetryError: httpconnectionPool(host=\'127.0.0.1\',port=34780): Max retries exceeded with url: /session/46cb728d61ec7389a9b40b225692ebfb/element (Caused by NewConnectionError(\'<urllib3.connection.httpconnection object at 0x7fe92676cef0>: Failed to establish a new connection: [Errno 111] Connection refused\',))\n\nDuring handling of the above exception,another exception occurred:\n\nTraceback (most recent call last):\n File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py",line 160,in _new_conn\n (self._dns_host,self.port),self.timeout,**extra_kw\n File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py",line 84,in create_connection\n raise err\n File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py",line 74,in create_connection\n sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。