Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nicegui/testing/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class Screen:
PORT = 3392
IMPLICIT_WAIT = 4
PAGE_LOAD_TIMEOUT = 4
SCREENSHOT_DIR = Path('screenshots')
CATCH_JS_ERRORS = True

Expand Down Expand Up @@ -75,10 +76,13 @@ def stop_server(self) -> None:
if core.loop:
assert core.loop.is_closed()

def open(self, path: str, timeout: float = 3.0) -> None:
def open(self, path: str, timeout: float = 3 * PAGE_LOAD_TIMEOUT) -> None:
"""Try to open the page until the server is ready or we time out.

If the server is not yet running, start it.

The timeout must stay above ``PAGE_LOAD_TIMEOUT``: a single slow page load already
consumes that much, so a smaller budget would leave no room to retry.
"""
if self.server_thread is None:
self.start_server()
Expand Down
2 changes: 1 addition & 1 deletion nicegui/testing/screen_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def nicegui_driver(nicegui_chrome_options: webdriver.ChromeOptions) -> Generator
else: # no break
raise RuntimeError('Could not start Chrome WebDriver.')
driver_.implicitly_wait(Screen.IMPLICIT_WAIT)
driver_.set_page_load_timeout(4)
driver_.set_page_load_timeout(Screen.PAGE_LOAD_TIMEOUT)
yield driver_
driver_.quit()

Expand Down
Loading