Modern QA2026Frame Locators — tiles
Log inJoin
80 / 139 · 13 Browser Automation with Playwright · Advanced Locators← prev⊞ allnext →☰ Read as one page

8.5Frame Locators

Iframes are common in payment forms, third-party widgets, and legacy applications. Playwright provides frameLocator() to scope into frames.

// Scope into an iframe by CSS selector
const paymentFrame = page.frameLocator('#payment-iframe');
await paymentFrame.getByLabel('Card number').fill('4242424242424242');
await paymentFrame.getByLabel('Expiry').fill('12/28');
await paymentFrame.getByRole('button', { name: 'Pay' }).click();

// Scope into a named frame
const adFrame = page.frameLocator('iframe[name="ad-banner"]');

// Nested frames
const inner = page.frameLocator('#outer').frameLocator('#inner');
await inner.getByRole('button').click();