admin管理员组文章数量:1355103
I'm trying to automate an interaction with a dynamic iframe using K6 Browser, but I'm facing difficulties when trying to click a button inside that iframe. The code I'm using is as follows:
const myFrame = 'iframe[src^="/"][src*="embedded=true"]';
await page.waitForSelector(myFrame, {visible: true, timeout: 1000});
const iframeElement = await page.$(myFrame);
const iframeContent = await iframeElement.contentFrame();
await iframeContent.click('//button[text()="Assinar"]');
console.log(i)
console.log(myFrame)
The iframe URL is dynamic and changes over time, but it follows a pattern where the URL starts with / and contains embedded=true.
I get the following errors:
WARN[0052] Unexpected DevTools server error: context canceled category="ExecutionContext:eval" elapsed="0 ms" source=browser
ERROR[0052] Uncaught (in promise) clicking on "//button[text()=\"Subscribe\"]": timed out after 30s
I tried using waitForSelector
to wait for the iframe, but I still have issues.
Can anyone help me understand how I can handle dynamic iframe URL and click the button correctly inside it? What would be the best approach to do this, considering that the iframe URL is dynamic?
本文标签: javascripthow to find an element inside an iframe in k6browserStack Overflow
版权声明:本文标题:javascript - how to find an element inside an iframe in k6browser? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744034145a2579454.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论