Skip to main content

等待

🌐 Waiting

browser_wait_for

在继续之前等待一个条件。接受三种模式之一:

🌐 Wait for a condition before proceeding. Accepts one of three modes:

参数类型描述
time数字等待的秒数
text字符串出现在页面上的文本
textGone字符串从页面消失的文本

等待文本出现

🌐 Wait for text to appear

→ browser_wait_for { text: "Upload complete" }
✓ Text appeared: "Upload complete"

等待文字消失

🌐 Wait for text to disappear

→ browser_wait_for { textGone: "Loading..." }
✓ Text disappeared: "Loading..."

等待固定时间

🌐 Wait a fixed duration

→ browser_wait_for { time: 3 }
✓ Waited 3 seconds

工作流:等待异步操作

🌐 Workflow: waiting for async operations

You: Click the upload button and wait for it to finish.

→ browser_click { ref: "e9" }
→ browser_snapshot
- progressbar "Uploading..." [ref=e12]

→ browser_wait_for { textGone: "Uploading..." }
→ browser_snapshot
- text: "Upload complete! File saved."
- link "View file" [ref=e15]

对于更复杂的等待条件(CSS选择器、JavaScript表达式),请使用 browser_run_code

🌐 For more complex wait conditions (CSS selectors, JavaScript expressions), use browser_run_code:

→ browser_run_code {
code: "async (page) => { await page.waitForSelector('.data-loaded'); }"
}