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

Unable to use selenium-wire with a specific webpage inside gitlab #575

Closed alex4200 closed 2 years ago

alex4200 commented 2 years ago

I have a very strange and weird problem with selenium-wire. When I try to use selenium-wire with seleniumbase I am unable to open the page https://courseware.epfl.ch/ when I run the code inside gitlab.

Running the same code locally but with the exact same environment (outside gitlab) does work. It also works for other pages. But not for this specific page inside gitlab.

Asked differently: How can I modify this code below so it works with selenium-wire in order to record the requests being made:

import json
import time
import datetime

from seleniumbase import BaseCase
from seleniumwire import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, ElementNotVisibleException

class MyTestClass(BaseCase):

    def log(self, text):
        timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
        print(f"{timestamp}: {text}")

    def open_page(self, url, filename):

        self.log(f"Login: Opening page {url}")
        self.open(url)
        self.log("Opened page")
        time.sleep(10)
        self.save_screenshot("debug/" + filename)

    def test_base(self):

        self.open_page("https://courseware.epfl.ch", "courseware.png")
alex4200 commented 2 years ago

The issue seem to have been related to how NO_PROXY is defined.