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 251 forks source link

Opening a webpage with seleniumbase and selenium-wire gives error "session deleted because of page crash" #613

Closed alex4200 closed 1 year ago

alex4200 commented 1 year ago

I am trying to use selenium-wire 5.1.0 with seleniumbase 3.3.3 using chrome 105.0.5195.125 with Python 3.8.15 & pytest-7.1.2 to open a webpage, but it gives the following error:

>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
E       from unknown error: cannot determine loading status
E       from tab crashed
E         (Session info: chrome=105.0.5195.125)
E       Stacktrace:
E       #0 0x559e654ef693 <unknown>
E       #1 0x559e652e89db <unknown>
E       #2 0x559e652d6617 <unknown>
E       #3 0x559e652d5f8f <unknown>
E       #4 0x559e652d5389 <unknown>
E       #5 0x559e652d3fd0 <unknown>
E       #6 0x559e652d450c <unknown>
E       #7 0x559e652e0dff <unknown>
E       #8 0x559e652e1992 <unknown>
E       #9 0x559e652f0452 <unknown>
E       #10 0x559e652f4324 <unknown>

(complete, overlength full output on request).

I am defining the driver in conftest.py as

@pytest.fixture()
def driver(request):
    """Defines the modified selenium base object to contain custom driver."""

    class BaseClass(BaseCase):
        """Seleniumbase class definition."""
        def setUp(self):
            """Setting up the seleniumbase object."""
            super().setUp()
            self.driver.close()
            self.driver.quit()
            warnings.simplefilter("ignore", category=DeprecationWarning)
            self.driver = webdriver.Chrome()

        def tearDown(self):
            """Tearing down up the seleniumbase object."""
            self.save_teardown_screenshot()
            super(BaseClass, self).tearDown()

        def base_method(self):
            """Required method"""
            pass

    sb = BaseClass()
    sb.setUp()
    yield sb
    sb.tearDown()

and the actual test is as follows:


def test_1(driver):
    print("opening webpage")
    driver.open("https://bbp.epfl.ch/ngv-portal/anatomy/reconstruction-data")
    print("Webpage has been opened")

When using the standard seleniumbase driver I do not get this error, and the open command does work without problems. Only when I use the selenium-wire driver I get this problem.

mdmintz commented 1 year ago

@alex4200 SeleniumBase 4.7.0 adds selenium-wire integration: https://github.com/seleniumbase/SeleniumBase/issues/1574 Use pytest --wire when calling your tests, and things should just work.