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

Stuck request results in page never loading #328

Closed muusfa closed 3 years ago

muusfa commented 3 years ago

Hello, I ran into some issues when trying to use selenium-wire to mock responses for my end to end tests.

When I use selenium the exact same web page seems to load fine and no issues occur. But when I try to load the exact same page with selenium-wire, the page does not load and this is due to requests being stuck (checked using the network tools panel in chrome). I get the following error:

Failed to load resource: net::ERR_TIMED_OUT

The only line of code that changes between me getting an error is below:

from seleniumwire import webdriver website stalls

from selenium import webdriver website works fine

I believe it might have to do with a proxy issue? Is there a way to bypass selenium-wire for specific requests? Are there any recommendations you might have on trying to resolve this issue?

Thanks.

wkeeling commented 3 years ago

Thanks for raising this.

You can bypass Selenium Wire for entire hosts using the exclude_hosts option. On a per-request basis you'd need to use driver.scopes, but these requests still physically pass through Selenium Wire even though they're not captured, so may suffer from the same issue you're seeing.

Are you able to share the code that you're using, including any options you're passing to the webdriver instance?

muusfa commented 3 years ago

Hi, thank you for your quick response. Yes I believe neither exclude_hosts or driver.scopes is the correct option for me. Please see the code below to see what I do.

from behave import *
from seleniumwire import webdriver

@given(u'open chrome browser')
def step_impl(context):

    context.browser = webdriver.Chrome()

@when('open NCD2 planning portal with site AB0131')
def step_imp(context):
    context.browser.maximize_window()
    context.browser.get(
        "http://localhost:3001/planning/AB0131")