Skip to content

Commit

Permalink
refactor: param name network_idle_timeout -> timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
idiotWu committed Jan 25, 2025
1 parent 4c24888 commit de5e87f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions npiai/core/tool/_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,23 @@ async def load_page(
ctx: Context,
url: str,
wait_for_selector: str = None,
network_idle_timeout: int | None = None,
timeout: int | None = None,
force_capcha_detection: bool = False,
):
await self.playwright.page.goto(url)

if wait_for_selector is not None:
try:
locator = self.playwright.page.locator(wait_for_selector)
await locator.first.wait_for(
state="attached", timeout=network_idle_timeout
)
await locator.first.wait_for(state="attached", timeout=timeout)
except TimeoutError:
await self.detect_captcha(ctx)
# wait for the page to become stable
elif network_idle_timeout is not None:
elif timeout is not None:
try:
await self.playwright.page.wait_for_load_state(
"networkidle",
timeout=network_idle_timeout,
timeout=timeout,
)
except TimeoutError:
pass
Expand Down

0 comments on commit de5e87f

Please sign in to comment.