k6-docs icon indicating copy to clipboard operation
k6-docs copied to clipboard

Working with `iframe`s

Open ankur22 opened this issue 2 months ago • 0 comments

What

Elements inside iframes are not accessible through the main page context, usually due to CORS restrictions.

Solution

Use locator.contentFrame() to access iframe content, e.g.:

await page.locator('#iframe').contentFrame().getByRole('button').click();

This requires the user to understand the website architecture or be able to work with the devtools window in their web browser.

In the future the hope is that they can work with k6 Studio which will be able to find suitable selectors and create the browser test script for them as they click through on their website.

ankur22 avatar Oct 01 '25 08:10 ankur22