[英]How to find IFRAMES and their elements inside without the id?
详细信息:该机器人有 function 用于填写表单中的回复,但该表单位于页面上的 iframe 中。 但是,它没有标识(名称、ID、class 等),只有来源 (scr)。
我试图找到替代方案,但找不到。 有人有什么想法吗?
想法是使用 PLAYWRIGHT 库将数据插入 iframe 中的表单
如果您的页面只有一个没有名称的框架,则可以使用以下方法:
page.frame_locator("iframe").locator("#myfield").click()
page.frame_locator("iframe").locator("#myfield").fill("hello world")
如果您的页面有多个带有名称的框架,您将不得不求助于 .nth() ,这并不好:
page.frame_locator("iframe >> nth=0").locator("#myfield").click() page.frame_locator("iframe >> nth=0").locator("#myfield").fill("aaa")
page.frame_locator("iframe >> nth=1").locator("#myfield").click()
page.frame_locator("iframe >> nth=1").locator("#myfield").fill("bbb")
page.frame_locator("iframe >> nth=2").locator("#myfield").click()
page.frame_locator("iframe >> nth=2").locator("#myfield").fill("ccc")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.