gpt4 book ai didi

Java- Selenium : containing problematic

转载 作者:行者123 更新时间:2023-11-30 03:54:27 26 4
gpt4 key购买 nike

我正在使用 Java 和 Selenium API 测试网页。网页是这样完成的:

<html>
<head>
</head>
<frameset name="f1">
<html>
<frameset name="f2">
</frameset>
</html>
</frameset>
</html>

使用internetExplorerDriver.findElement(By.xpath("//frame[@name='f1']"))好的元素被检索到。但是当我这样做时internetExplorerDriver.findElement(By.xpath("//frame[@name='f2']"))它告诉我们找不到该元素。当我用f1.findElements(By.xpath("*")).size();查看f1的 child 时我得到 0,没有找到 child 。

如何解决这个问题?是否需要更改网页并删除子 html 标记?提前致谢。

问候,让·杜克罗

最佳答案

您需要先切换到框架,然后才能在框架上下文中查找元素。

internetExplorerDriver.switchTo().frame("f1");
internetExplorerDriver.findElement(By.xpath("//frame[@name='f2']"))

关于Java- Selenium : <html> containing <html> problematic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23611081/

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