wait_for
Pause execution until a specified element appears on the page or a network request matching a URL pattern is detected. Define a timeout to control wait duration.
Instructions
Wait for an element to appear or a network request matching a URL pattern.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | No | ||
| url_pattern | No | ||
| timeout | No |
Implementation Reference
- Handler function for the 'wait_for' MCP tool. Waits for a DOM element (via selector) or a URL pattern match on the active page.
@mcp.tool() async def wait_for( selector: str | None = None, url_pattern: str | None = None, timeout: int = 30000, ) -> dict: """Wait for an element to appear or a network request matching a URL pattern.""" try: page = await browser_manager.get_active_page() if selector: await page.wait_for_selector(selector, timeout=timeout) return {"status": "found", "selector": selector} elif url_pattern: await page.wait_for_url(url_pattern, timeout=timeout) return {"status": "matched", "url_pattern": url_pattern} else: return {"error": "Provide either selector or url_pattern"} except Exception as e: return {"error": str(e)} - Input schema/type annotations for the wait_for tool: optional selector (str), optional url_pattern (str), and timeout (int, default 30000ms).
async def wait_for( selector: str | None = None, url_pattern: str | None = None, timeout: int = 30000, ) -> dict: - src/camoufox_reverse_mcp/tools/navigation.py:335-335 (registration)Registration of wait_for as an MCP tool via the @mcp.tool() decorator on the FastMCP instance 'mcp' from server.py.
@mcp.tool()