I have this button that’s nested in a form within a document, that’s also nested in two iframes. I’ve been able to get access elements of the first iframe and able to get the name of the iframe that is nested within. The problem is I can’t seem to preform a click action on the button in question.
const iframeHandle = page.waitForSelector('//iframe');
const frame = iframeHandle.contentFrame();
let confirmFrameHandle = frame.waitForSelector('iframe[id*="SomeID"]');
let confirmFrame = confirmFrameHandle.contentFrame();
console.log("name",confirmFrame.name()); // This returns the name of the Iframe I wish to work on at least
//Cannot seem to find this button within the Iframe!
const button = confirmFrame.waitForSelector('//button[text()="Confirm"]');
button.click();
I’ve tried console logging the forms around the button as well to no avail. Wondering if there is anyway about this.
I haven’t tried to reproduce this bug locally yet. Still, it should be quite easy to find this bug. It would be great if you could post your test HTML and script here to quicken up our process (maybe or @maxahudson). So we can reproduce the error and possibly come up with a fix.
@ankur
The webpage only generates the second Iframe in the test environment (which requires access) as it simulates accepting a card payment.
I do go one level down and the test times out when trying for the button.
@bandorko
I tried the work around to no avail, it may be due to the fact it’s nested within a form, not quite sure myself.
Thanks in advanced, also surprised at your fast replies.
On my computer I was able to click the Yes button also with the workaround. I had to fix the HTML you posted, because it is not valid. (there are 4 </iframe> , but just 2 <iframe>, and I had to split it into 3 HTMLs because as far as I know iframe tag doesn’t support content, but you have to use the src attribute instead)
My apologies, the closing tags at the end are the right ones.
I’m still not able to find the button at all, keeps running till timeout at the waitForSelector part.
I get
panic: GoError: dispose: canceled
After the 7 minute mark.
These iFrames are created by a third party, so have no control over the layouts of the html. Have also enabled bypassCSP: true, just in case, even though I never had the issue occur in the console.
Which log messages do you see in the console? confirmFrame found, button found, button clicked. I’d like to know where the script stuck.
And which version of k6 do you use?
I get the ConfirmFrame found then it just runs for 7 minutes, so never gets to the button found part.
I’m running k6 v0.46.0 Which I assume is the latest.
At the moment the latest version is v0.47.0, but for me it works with v0.46.0 also.
So I think there may be some difference between our HTML contents. I assume, that, the iframe with someID is not the only one in your case, because I can reproduce your behavior, when I modify my iframe.html, and add an another iframe before the SomeID iframe. In this case my script doesn’t find the button either. (If I add the second iframe below the someID, then the script finds the button)
I saw that you’ve released a supposed fix for this in v0.48.0, although I still seem to be getting a panic. Is there some form of document that could be of use?