admin管理员组文章数量:1225070
I have a trivial question that I can't find an answer to using Microsoft Playwright framework. According to documentation you can fetch an iframe with the following code:
const frame = page.frame('frame-login');
But how do I use a selector to find and interact with an iframe? I need to use a CSS selector to find my iframe since it does not have an id.
Any help appreciated
I have a trivial question that I can't find an answer to using Microsoft Playwright framework. According to documentation you can fetch an iframe with the following code:
const frame = page.frame('frame-login');
But how do I use a selector to find and interact with an iframe? I need to use a CSS selector to find my iframe since it does not have an id.
Any help appreciated
Share Improve this question edited Feb 19, 2023 at 21:01 ggorlen 57k8 gold badges110 silver badges150 bronze badges asked Jun 26, 2020 at 13:40 ei0haroei0haro 911 gold badge1 silver badge2 bronze badges2 Answers
Reset to default 11You can use elementHandle.contentFrame()
await page.waitForSelector('.class-name')
const elementHandle = await page.$('.class-name')
const frame = await elementHandle.contentFrame()
From that moment you can interact with the content of the <iframe>
like: await frame.<method_name>
.
You can get the ElementHandle
calling $
and then call the contentFrame function:
const handle = await page.$('.frame');
const contentFrame = await handle.contentFrame();
本文标签: javascriptHow to use a selector finding an frame (iframe) using PlaywrightStack Overflow
版权声明:本文标题:javascript - How to use a selector finding an frame (iframe) using Playwright - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739411265a2162068.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论