selenium-wire
selenium-wire copied to clipboard
Doesn't work offline despite having a catch-all request interceptor
Sample code
With internet disabled, run:
def interceptor(request):
# Intercept all requests
request.create_response(
status_code=200,
headers={'Content-Type': 'text/html'}, # Optional headers dictionary
body='<html>Hello World!</html>' # Optional body
)
# Create a new instance of the Chrome driver
driver = webdriver.Chrome()
driver.request_interceptor = interceptor
# Go to the Google home page
driver.get('https://www.google.com')
# Access requests via the `requests` attribute
for request in driver.requests:
if request.response:
print(
request.url,
request.response.status_code,
request.response.headers['Content-Type']
)
Expected behaviour
When using a "catch-all" mock, I would expect there to be no outbound requests, thus permitting use offline.
This should then print the response created in the interceptor
eg:
Actual behaviour
As the name resolution fails, we get:
Is it possible to prevent this lookup from happening also, thus allowing offline use?