gpt4 book ai didi

java - 使用 Selenium 和 java 识别页面中 iframe 的数量?

转载 作者:行者123 更新时间:2023-12-02 14:23:45 24 4
gpt4 key购买 nike

Selenium 中有没有方法可以识别以下内容?

Number of iframes in a page
Attributes/Details of the current iframe

最佳答案

driver.findElements(By.xpath("//iframe")).size();

为了获取当前帧的详细信息,我建议您使用 WebElement 切换到它。对象和switchTo ,然后像平常一样使用 getAttribute 获取属性

UPD

事实上,是的,首先会给出当前上下文中 iframe 的数量。如果您不想递归地执行此操作,但想要一个快速且有效的(脏)解决方案 - 只需获取页面源代码并找到 "<iframe" 的所有包含内容即可字符串

关于java - 使用 Selenium 和 java 识别页面中 iframe 的数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31532534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com