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

How to stop seleniumwire from dissalowing sites to do requests? #251

Closed Avnsx closed 3 years ago

Avnsx commented 3 years ago

I literaly can't click any button that would launch a request to another site, when using selenium wire. It partially even dissalows the websites request to load, on this website the authorize apis button for example will always throw an error because it can't connect to it's backend

wkeeling commented 3 years ago

It seems OK when I visit https://developers.google.com/oauthplayground/, select some APIs and press the 'Authorize APIs' button.

Can you share the code you're using?

Avnsx commented 3 years ago

I use it in combination with undetected chromedriver, I would share the code but it's just the basic integration with driver.get to the website and then it clicks that button after entering an api url and that's it. unfortunately i'm not at home right now, but for me it always acts up for example i can't even navigate to any other site either when i type an url into seleniumwire controlling chromdriver it just keeps saying no connection to the internet, unless it's pre-written in the code that it should go to that website. Is that normal?

wkeeling commented 3 years ago

I managed to get the above code to work, but I needed to add an explicit time.sleep() after the request to set the scope. Without the sleep, it seems that the first WebDriverWait() call doesn't wait long enough for the Authorize APIs button to enable itself. So I did:

WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#scopes'))).send_keys('https://www.googleapis.com/auth/cloud-platform')
time.sleep(3)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#authorizeApisButton'))).click()

I didn't see any other errors though, so perhaps there's something else happening in your environment.