> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.airtop.ai/guides/how-to/ai/monitoring-a-page/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.airtop.ai/_mcp/server. # Monitoring a Page You can use the `monitor` method to intelligently monitor web pages for specific conditions. This method uses AI to understand and evaluate natural language conditions, making it easy to wait for specific states or changes in web applications without writing complex selectors or assertions. The Monitor API is particularly powerful for dynamic web applications where you need to wait for specific states that might be difficult to detect with traditional selectors. It can understand complex conditions involving multiple elements, text content, visual states, and more. ### Usage example First, you'll need to create a session. **`NodeJS`** ```typescript NodeJS const session = await client.sessions.create(); ``` **`Python`** ```python Python session = client.sessions.create() ``` Next, you'll need to create a window and load a URL. **`NodeJS`** ```typescript NodeJS const window = await client.windows.create(session.data.id, { url: "https://example.com/login" }); ``` **`Python`** ```python Python window = client.windows.create(session.data.id, url="https://example.com/login") ``` Now you can monitor for a condition. Here's an example waiting for a successful login: **`NodeJS`** ```typescript NodeJS const result = await client.windows.monitor(session.data.id, window.data.windowId, { condition: "Determine if the user appears to be signed in to the website", configuration: { interval: { intervalSeconds: 5, // Check every 5 seconds timeoutSeconds: 30 // Stop after 30 seconds }, includeVisualAnalysis: "enabled" // Enable visual analysis for better detection } }); ``` **`Python`** ```python Python monitor_config = MonitorConfig( # Enable visual analysis include_visual_analysis="enabled", # Configure interval settings interval=IntervalMonitorConfig( interval_seconds=10, # Check every 10 seconds timeout_seconds=300 # Stop after 5 minutes ) ) result = client.windows.monitor( session_id=session.data.id, window_id=window.data.window_id, condition="Determine if the user appears to be signed in to the website", configuration=monitor_config ) ``` The response will include a `conditionMet` boolean indicating whether the condition was met, and optionally a `reason` explaining why the condition was not met. ### Example Conditions Here are some examples of conditions you can monitor for: * "Wait for the success message to appear after form submission" * "Check if the shopping cart contains more than 3 items" * "Determine if the error message is visible" * "Wait for the loading spinner to disappear" * "Check if the table has been populated with data" ### Configuration Options You can customize the monitoring behavior with these options: #### Interval Configuration * `intervalSeconds`: How frequently to check the condition (default: 5 seconds) * `timeoutSeconds`: Maximum time to wait for the condition (default: 30 seconds) #### Visual Analysis * `includeVisualAnalysis`: Enable visual analysis for enhanced condition detection * `"auto"`: Let the system decide (default) * `"enabled"`: Always use visual analysis * `"disabled"`: Never use visual analysis #### Resource Management * `costThresholdCredits`: Set credit limits for the monitoring operation * `timeThresholdSeconds`: Set maximum execution time limits > **Note** > > When visual analysis is enabled, monitoring operations may use more credits but can detect visual changes more > accurately. This is particularly useful for conditions that involve visual states like "Check if the button is grayed > out" or "Wait for the success icon to appear". ``` ``` > Monitor web pages for conditions using AI