I am trying to navigate to iframe and come back to top frame using selenium.
<html>
<body>
<div id="testID">This is upper frame</div>
<iframe src="test.html"></iframe>
</body>
</html>
I want to get the testID which I am getting easily using driver.findElement(By.id("testID"))
.
And then I want to navigate to iframe using driver.switchTo().frame(driver.findElement(By.id("new_page")));
where new_page
is the id inside test.htm
.
Now, my requirement is to switch back so that I can again read testID
from the above body.
But if I use:
driver.switchTo().frame(driver.findElement(By.id("testID")));
I am getting exception like:
unable to locate element