wait_for
Pauses script execution until a specified web element becomes available on the page, using CSS selectors to identify elements and optional timeout settings.
Instructions
Wait for an element to appear on the page
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>"
},
"name": "wait_for"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the element to wait for | |
| timeout | No | Timeout in milliseconds (default: 5000) |
Implementation Reference
- tools-playwright.js:227-230 (handler)Handler function for the 'wait_for' MCP tool. Delegates to browser.waitFor method.
handler: async ({ selector, timeout = 5000 }) => { await browser.waitFor(selector, timeout); return { success: true, message: `Element ${selector} appeared within ${timeout}ms` }; } - tools-playwright.js:219-226 (schema)Input schema definition for the 'wait_for' tool.
inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to wait for' }, timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' } }, required: ['selector'] }, - tools-playwright.js:216-231 (registration)Full registration of the 'wait_for' tool in createPlaywrightTools array.
{ name: 'wait_for', description: 'Wait for an element to appear on the page', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to wait for' }, timeout: { type: 'number', description: 'Timeout in milliseconds (default: 5000)' } }, required: ['selector'] }, handler: async ({ selector, timeout = 5000 }) => { await browser.waitFor(selector, timeout); return { success: true, message: `Element ${selector} appeared within ${timeout}ms` }; } }, - browser.js:121-124 (helper)Core waitFor helper method in SimpleBrowser class that uses Playwright's waitForSelector.
async waitFor(selector, timeout = 5000) { await this.ensureLaunched(); await this.page.waitForSelector(selector, { timeout }); }