in src/nova_act/impl/extension.py [0:0]
def wait_for_page_to_settle(self, go_to_url_timeout: int | None = None) -> None:
"""
Dispatch a page state query to extension and wait for confirmation of settled.
"""
page_state = PageState(self._session_id)
if go_to_url_timeout is None:
go_to_url_timeout = MAX_WAIT_FOR_PAGE_TO_SETTLE_TIMEOUT
self._playwright_manager.window_message_handler.bind_page(page_state)
request_wait_for_page_state_message = {
"type": WAIT_FOR_PAGE_TO_SETTLE_PROMPT_TYPE,
"apiKey": self._nova_act_api_key,
"uuid": str(uuid.uuid4()),
"hostname": self._backend_info.api_uri,
"sessionId": self._session_id,
"useBedrock": True,
"maxTimeout": go_to_url_timeout,
}
encrypted_message = self._playwright_manager.encrypter.encrypt(request_wait_for_page_state_message)
try:
self._playwright_manager.main_page.evaluate(POST_MESSAGE_EXPRESSION, encrypted_message)
except PlaywrightError:
if self._verbose_errors:
_LOGGER.error("Encountered PlaywrightError", exc_info=True)
end_time = time.time() + EXTENSION_TIMEOUT_S + go_to_url_timeout
while time.time() < end_time:
if page_state.is_settled:
return
else:
self._poll_playwright(EXTENSION_POLL_SLEEP_S)
_LOGGER.warning(f"Page not settled after {go_to_url_timeout}s")