navigate
Opens a web page by navigating to a specified URL. Optionally waits for the page to fully load, ensuring content is ready for subsequent automation tasks.
Instructions
Navigate to a URL
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to navigate to | |
| waitForLoad | No | Wait for page to fully load |
Implementation Reference
- src/index.ts:23-26 (schema)Zod schema for the 'navigate' tool input: requires a valid URL string, with an optional boolean 'waitForLoad' that defaults to true.
const NavigateSchema = z.object({ url: z.string().url(), waitForLoad: z.boolean().default(true) }); - src/index.ts:158-176 (registration)Tool registration entry for 'navigate' in the ListToolsRequestSchema handler, defining name, description, and inputSchema (url string required, waitForLoad boolean optional with default true).
{ name: 'navigate', description: 'Navigate to a URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to navigate to' }, waitForLoad: { type: 'boolean', default: true, description: 'Wait for page to fully load' } }, required: ['url'] } }, - src/index.ts:458-481 (handler)Handler implementation for the 'navigate' tool: checks if a browser page is available, parses args with NavigateSchema, navigates to URL via Playwright's page.goto() (using 'networkidle' if waitForLoad is true), retrieves the page title, and returns a success message with the URL and title.
case 'navigate': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = NavigateSchema.parse(args); if (params.waitForLoad) { await currentPage.goto(params.url, { waitUntil: 'networkidle' }); } else { await currentPage.goto(params.url); } const title = await currentPage.title(); return { content: [ { type: 'text', text: `Navigated to ${params.url}\nPage title: ${title}` } ] }; }