wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

Selenium Wire not capturing Localhost running requests #166

Closed JanuLakshmanan closed 3 years ago

JanuLakshmanan commented 3 years ago

I tried to capture the requests of an application running in my xampp server. But nothing gets captured.

URL : http://localhost:3000/#/

Whether Do i need to specify any options in driver ? Help me out!

wkeeling commented 3 years ago

Are you able to post the code you're using to create the webdriver?

JanuLakshmanan commented 3 years ago

from seleniumwire import webdriver

driver = webdriver.Chrome()

Go to the Google home page

driver.get('http://localhost:3000/#/')

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'] )

This is the code snippet .But here it didn't print any requests of that given URL

pastpatryk commented 3 years ago

I'm experiencing the same problem. It's capturing requests from remote apps, but when I try to run it on localhost (or 127.0.0.1) nothing gets captured.

wkeeling commented 3 years ago

Selenium Wire instructs the browser not to bypass localhost addresses, but it could be that your browser or system proxy configuration is set up to override that. If you open your system proxy settings (on Windows search for "proxy" from the Start menu), can you see if there is an entry for localhost anywhere?

pastpatryk commented 3 years ago

@JanuLakshmanan I managed to fix that problem by adding this:

options = webdriver.ChromeOptions()
options.add_argument("proxy-bypass-list=<-loopback>")
driver = webdriver.Chrome(options=options)

I found this solution in one of the previous issues: https://github.com/wkeeling/selenium-wire/issues/157

wkeeling commented 3 years ago

Good catch @pastDexter . Must add that as part of the next release.