Closed 097115 closed 3 years ago
Thanks for this. I'm sure we can improve the error logging here. Just so I'm looking at the correct place in the code, is there a traceback you can share, or alternatively a URL that exhibits the problem so I can reproduce?
Hi! Thanks for your answer!
For some reason, I can't reliably reproduce but something like this:
#!/usr/bin/env python3
from seleniumwire import webdriver
firefox_options = webdriver.FirefoxOptions()
firefox_options.headless = True
firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['pageLoadStrategy'] = 'eager'
sw_options = {
'suppress_connection_errors': True
}
driver = webdriver.Firefox(capabilities=firefox_capabilities,
options=firefox_options,
seleniumwire_options=sw_options,
service_log_path='/dev/null')
u = 'https://www.google.com'
x = '/html/body/div[3]'
driver.get(u)
driver.implicitly_wait(30)
try:
driver.find_element_by_xpath(x).click()
except:
print("ERROR: the layer wasn't found!")
driver.quit()
...may effect in something like this:
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Error making request
Traceback (most recent call last):
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 85, in proxy_request
conn.request(self.command, path, req_body, dict(req.headers))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 950, in send
self.connect()
File "/Users/097115/Library/Python/3.9/lib/python/site-packages/seleniumwire/proxy/proxy2.py", line 364, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1417, in connect
super().connect()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
At first I thought it's my hosts file blocking some crap connections. But now I'm not really sure...
Thanks - that's useful to have. I actually tried reproducing by modifying my local hosts file to send certain hosts to an invalid IP, but it didn't seem to generate the OSError
s. Anyway, now I have the tracebacks above, I'll look at catching and suppressing the error with the suppress_connection_errors
option. Many thanks.
Version 3.0.5 now available which suppresses all connection related errors by default. These can be made visible by setting the suppress_connection_errors
option to False
in the seleniumwire_options
.
Thanks, Will!
Is it possible NOT to print out every
OSError: [Errno 65] No route to host
andConnectionRefusedError: [Errno 61] Connection refused
error?Tried setting
suppress_connection_errors
toTrue
like this:...but somehow this didn't help.
Python 3.9.1 selenium 3.141.0 selenium-wire 3.0.4