MCPcopy
hub / github.com/streamlit/streamlit / wait_for_app_run

Function wait_for_app_run

e2e_playwright/conftest.py:1599–1661  ·  view source on GitHub ↗

Wait for the given page to finish running. Parameters ---------- page_or_locator : Page | Locator | FrameLocator The page or locator to wait for. wait_delay : int, optional The delay to wait for the rerun to finish. initial_wait : int, optional The initia

(
    page_or_locator: Page | Locator | FrameLocator,
    wait_delay: int = 100,
    initial_wait: int = 210,
)

Source from the content-addressed store, hash-verified

1597
1598
1599def wait_for_app_run(
1600 page_or_locator: Page | Locator | FrameLocator,
1601 wait_delay: int = 100,
1602 initial_wait: int = 210,
1603) -> None:
1604 """Wait for the given page to finish running.
1605
1606 Parameters
1607 ----------
1608 page_or_locator : Page | Locator | FrameLocator
1609 The page or locator to wait for.
1610 wait_delay : int, optional
1611 The delay to wait for the rerun to finish.
1612 initial_wait : int, optional
1613 The initial wait before checking for the rerun to finish.
1614 This is needed for some widgets that have a debounce timeout.
1615 For example, pydeck charts have a debounce timeout of 200ms.
1616 """
1617
1618 page: Page
1619 if isinstance(page_or_locator, Locator):
1620 page = page_or_locator.page
1621 elif isinstance(page_or_locator, FrameLocator):
1622 page = page_or_locator.owner.page
1623 else:
1624 page = page_or_locator
1625
1626 page.wait_for_timeout(initial_wait)
1627
1628 if isinstance(page_or_locator, StaticPage):
1629 # Check that static connection established.
1630 page_or_locator.locator(
1631 "[data-testid='stApp'][data-test-connection-state='STATIC_CONNECTED']"
1632 ).wait_for(
1633 timeout=25000,
1634 state="attached",
1635 )
1636 else:
1637 # Make sure that the websocket connection is established.
1638 page_or_locator.locator(
1639 "[data-testid='stApp'][data-test-connection-state='CONNECTED']"
1640 ).wait_for(
1641 timeout=25000,
1642 state="attached",
1643 )
1644
1645 # Wait until we know the script has started. We determine this by checking
1646 # whether the app is in notRunning state. (The data-test-connection-state attribute
1647 # goes through the sequence "initial" -> "running" -> "notRunning").
1648 page_or_locator.locator(
1649 "[data-testid='stApp'][data-test-script-state='notRunning']"
1650 ).wait_for(
1651 timeout=25000,
1652 state="attached",
1653 )
1654
1655 # Wait for all element skeletons to be removed.
1656 # This is useful to make sure that all elements have been rendered.

Calls 2

locatorMethod · 0.80
get_by_test_idMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…