diff --git a/nicegui/testing/screen.py b/nicegui/testing/screen.py index 55327bc73..bd3cef892 100644 --- a/nicegui/testing/screen.py +++ b/nicegui/testing/screen.py @@ -26,14 +26,15 @@ class Screen: IMPLICIT_WAIT = 4 SCREENSHOT_DIR = Path('screenshots') - def __init__(self, selenium: webdriver.Chrome, caplog: pytest.LogCaptureFixture) -> None: + def __init__(self, selenium: webdriver.Chrome, caplog: pytest.LogCaptureFixture, port: int = PORT) -> None: self.selenium = selenium self.caplog = caplog + self.port = port self.server_thread: Optional[threading.Thread] = None - self.ui_run_kwargs = {'port': self.PORT, 'show': False, 'reload': False} + self.ui_run_kwargs = {'port': self.port, 'show': False, 'reload': False} self.connected = threading.Event() app.on_connect(self.connected.set) - self.url = f'http://localhost:{self.PORT}' + self.url = f'http://localhost:{self.port}' def start_server(self) -> None: """Start the webserver in a separate thread. This is the equivalent of `ui.run()` in a normal script."""