I see the iframe gets inserted into DOM after I click on some icon. So DOM gets updated dynamically. Once I am able to get this iframe element, I need to operate on some elements within it. There are also some shadow host elements within this iframe.
I tried following:
Attempt1:
const iframe = page.waitForSelector("#iframeId")
Attempt2:
const iFrameHandle = page.waitForSelector("#parentelement")
const iframe = iFrameHandle.contentFrame()
Attempt3:
page.mainFrame(), page.frames()
Last resort:
const iframeHandle = await page.waitForSelector(“#iframeId”, { state: ‘attached’, timeout: 10000 });
const iframe = await iframeHandle.contentFrame();
console.log("IFRAME: "+iframe);
console.log(“Iframe handle stringify:”, JSON.stringify(iframeHandle, null, 2));
Is there anything I need to add to the code after I click on the icon which loads the iframe and before I try to locate elements within the iframe ?
Is there any equivalent in k6 for switch to iframe in Selenium ?