0
我正在尝试导航到iframe并使用硒返回到顶部帧。如何在Selenium中切换和切换
<html>
<body>
<div id="testID">This is upper frame</div>
<iframe src="test.html"></iframe>
</body>
</html>
我想获得testID,我很容易使用driver.findElement(By.id("testID"))
。
然后我想使用driver.switchTo().frame(driver.findElement(By.id("new_page")));
导航到iframe,其中new_page
是test.htm
里面的id。
现在,我的要求是切换回来,以便我可以再次从上述正文中读取testID
。
但是,如果使用: driver.switchTo().frame(driver.findElement(By.id("testID")));
我得到的异常,如:
无法找到元素