Wait for x seconds (default 3) (max 30 seconds). This can be used to wait until the page is fully loaded.
(self, request: WaitRequest)
| 324 | ) |
| 325 | |
| 326 | async def wait(self, request: WaitRequest) -> ActionResult: |
| 327 | """Wait for x seconds (default 3) (max 30 seconds). This can be used to wait until the page is fully loaded.""" |
| 328 | # Cap wait time at maximum 30 seconds |
| 329 | # Reduce the wait time by 3 seconds to account for the llm call which takes at least 3 seconds |
| 330 | # So if the model decides to wait for 5 seconds, the llm call took at least 3 seconds, so we only need to wait for 2 seconds |
| 331 | # Note by Mert: the above doesnt make sense because we do the LLM call right after this or this could be followed by another action after which we would like to wait |
| 332 | # so I revert this. |
| 333 | actual_seconds = min(max(request.seconds - 3, 0), 30) |
| 334 | memory = f'Waited for {request.seconds} seconds' |
| 335 | logger.info(f'🕒 waited for {actual_seconds} seconds + 3 seconds for LLM call') |
| 336 | await asyncio.sleep(actual_seconds) |
| 337 | return ActionResult( |
| 338 | success=True, |
| 339 | message=f"Successfully waited for {request.seconds} seconds", |
| 340 | extra={"memory": memory} |
| 341 | ) |
| 342 | |
| 343 | async def click_element_by_index(self, request: ClickElementRequest) -> ActionResult: |
| 344 | """Click element by index. Only indices from your browser_state are allowed. Never use an index that is not inside your current browser_state. Set while_holding_ctrl=True to open any resulting navigation in a new tab.""" |
no test coverage detected