Playwright Frames框架

1.一个 Page(页面)可以包含一个或多个 Frame(框架)对象。每个页面都有一个主框架,页面级别的交互(如 click)默认在主框架中进行。

javascript 复制代码
// Locate element inside frame
const username = await page.frameLocator('.frame-class').getByLabel('User Name');
await username.fill('John');

2.页面可以使用 iframe HTML 标签附加额外的框架。这些框架可以用于框架内部的交互。

3.可以通过 page.frame() API 访问框架对象。

javascript 复制代码
// Get frame using the frame's name attribute
const frame = page.frame('frame-login');

// Get frame using frame's URL
const frame = page.frame({ url: /.*domain.*/ });

// Interact with the frame
await frame.fill('#username-input', 'John');
相关推荐
wuhuhuan8 天前
Day 5:元素操作进阶
playwright
wuhuhuan12 天前
Day 3:定位策略进阶
playwright
深蓝电商API1 个月前
移动端浏览器自动化:Playwright for Android 实战
爬虫·playwright
wuhuhuan1 个月前
playwright-getByAltText
ui·playwright
wuhuhuan1 个月前
playwright-getByLabel定位
playwright
深蓝电商API1 个月前
Playwright 多浏览器并发:同时操控 100 个 Chrome 实例
爬虫·playwright
深蓝电商API1 个月前
Playwright深入浅出:从入门到企业级项目实战
爬虫·playwright
深蓝电商API1 个月前
Playwright vs Puppeteer vs Selenium 2026终极对比
爬虫·selenium·puppeteer·playwright
xiaobai1781 个月前
pytest+playwright实现UI自动化(4)-上夹具fixture
ui·自动化·pytest·playwright