This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
frameLocator(selector)
Returns a
FrameLocator for a nested iframe that matches the given selector within this frame. Use this to chain frame locators for nested iframes.
Returns
Example
import { browser } from 'k6/browser';
export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
};
export default async function () {
const page = await browser.newPage();
try {
await page.setContent(`
<iframe id="outer" srcdoc="<iframe id='inner' srcdoc='<button>Submit</button>'></iframe>"></iframe>
`);
// Nested iframes: outer frame, then inner frame, then element
const button = page.frameLocator('#outer').frameLocator('#inner').locator('button');
await button.click();
} finally {
await page.close();
}
}

