Skip to main content

导航

🌐 Navigation

工具描述
browser_navigate访问一个网址
browser_navigate_back返回上一页
browser_close关闭页面

browser_navigate

在当前标签页打开一个网址。如果还没有标签页,会先创建一个。

🌐 Navigate to a URL in the current tab. If no tab is open yet, one is created.

参数类型必填描述
url字符串要导航到的 URL
You: Go to https://demo.playwright.dev/todomvc

→ browser_navigate { url: "https://demo.playwright.dev/todomvc" }

- Page URL: https://demo.playwright.dev/todomvc
- Page Title: React • TodoMVC

- heading "todos" [level=1] [ref=e3]
- textbox "What needs to be done?" [ref=e5]

非2xx的响应会在响应中显示为 - HTTP status: 402 Payment Required

🌐 Non-2xx responses are surfaced in the response as - HTTP status: 402 Payment Required.

about:data:javascript: 的网址是允许的。导航到 file:// 的网址会被阻止,除非服务器是用 --allow-unrestricted-file-access 启动的,并且来源可以通过 --allowed-origins / --blocked-origins 进一步限制。

browser_navigate_back

返回浏览器历史记录中的上一页。

🌐 Go back to the previous page in the browser history.

You: Go back to the previous page.

→ browser_navigate_back
→ Returns a snapshot of the previous page

browser_close

关闭页面。当浏览器上下文在客户端之间共享时会失败(--shared-browser-context)。

🌐 Close the page. Fails when the browser context is shared between clients (--shared-browser-context).

→ browser_close

重新装填并前进

🌐 Reloading and going forward

要重新加载,请再次访问相同的网址。要前进,或者在不重新解析 URL 的情况下重新加载,请使用 browser_run_code_unsafe

🌐 To reload, navigate to the same URL again. To go forward, or to reload without re-resolving the URL, use browser_run_code_unsafe:

→ browser_run_code_unsafe { code: "async (page) => { await page.reload(); }" }
→ browser_run_code_unsafe { code: "async (page) => { await page.goForward(); }" }

工作流程示例

🌐 Workflow example

You: Open the TodoMVC app, add an item, then go back to see
if the item persists.

→ browser_navigate { url: "https://demo.playwright.dev/todomvc" }
→ browser_type { target: "e5", text: "Buy groceries", submit: true }
→ browser_navigate { url: "https://example.com" }
→ browser_navigate_back
→ browser_snapshot

- heading "todos" [level=1] [ref=e3]
- textbox "What needs to be done?" [ref=e5]
- list [ref=e8]:
- listitem [ref=e9]:
- checkbox "Toggle Todo" [ref=e10]
- text: Buy groceries