我正在尝试选择一个驻留在 iframe 内并且可能驻留在其他 iframe 中的元素。
是否可以在(python)selenium中的某些(子)iframe中选择一个元素,而无需先选择iframe?有没有办法以某种方式“循环”每个 iframe 并检查在哪里可以找到我的元素...?
在元素、html 内容和 iframe 可能刚刚被加载的情况下如何做到这一点......?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
编写自己的递归查找器应该很容易。抱歉,我不懂 python,但在 Java 中它会是这样的:
public void findInAllFrames(WebElement e, String targetIdStr) { List l = e.findElements(By.tagName("iframe"));
for(int inx=0; inx targets = l.get(inx).findElements(By.id(targetIdStr));
if(targets.size()>0) {
// Do something with your targets
}
findInAllFrames(l.get(inx), targetIdStr);
}
}