java - 选择不是 iframe
问题描述
我有一个要查找的元素:
//div[contains(@class, 'bPageBlock')][.//*[.='Agreement Documents']]//div[@class='pbBody']//tr[contains(@class,'dataRow')]//a[text()='View']
问题是,这找到了两个元素,我只想要一个。一个在 iframe 下,一个不在。如果我想要 iframe 下的那个会很容易。我可以
//iframe///div[contains(@class, 'bPageBlock')][.//*[.='Agreement Documents']]//div[@class='pbBody']//tr[contains(@class,'dataRow')]//a[text()='View']
但是,正如您可能猜到的那样,我想要不在 iframe 下的那个。我不知道如何指定类似 //not iframe// 的内容。即使我可以, // 也会找到比 iframe 更低或更高的东西。
任何关于如何找到不在 iframe 下的建议。除此之外的根源和路径似乎都彼此相同。我尝试了很多不同的东西。
如果您想查看特定的 iframe:
<iframe frameborder="0" id="RLPanelFrame" name="RLPanelFrame" src="/emptyHtmlDoc.html" title="Hidden Frame - Ignore" style="height: 176px;"></iframe>
然后它下面有许多子单元,带有自动生成的无意义的 ID。
我不认为我可以使用 driver.find() 找到每个并获取完整的 xpath 并检查“iframe”,因为 selenium 没有 xpath 提取器。我想对于每一个我都可以继续获得父母,直到我到达 //html 或 //iframe 但这需要很长时间。
有什么建议么?这与 Java 和 Selenium
解决方案
推荐阅读
- python - 按日期和时间排序不起作用 SQLITE3 和 Python
- numpy - 关于训练深度学习 softmax 分类器的目标数据大小的问题
- java - 如何为子类创建复制构造函数
- r - knitr 不编译 pdf
- c# - 从 php 到 c#:字典数组,还是字典字典?
- java - 如何访问 Oracle Java 资源以导入 Java 源
- react-native - React Native 让孩子填满所有可用空间
- android - 如何修复“在 null 上调用了 getter “文档”。飘飘然
- mysql - 将 4 字节的 unicode 字符插入 MySQL/MariaDB
- python - 在 tkinter 窗口内显示 networkx 图