k6-docs
k6-docs copied to clipboard
Working with `iframe`s
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.