Code Trails:

List<WebElement> before = driver.findElements(By.tagName("iframe"));

for (WebElement t : before) {
    System.out.println("iframe" + t.getAttribute("src"));

List<WebElement> after = driver.findElements(By.tagName("iframe"));
for (WebElement t : after) {
 System.out.println("iframe" + t.getAttribute("src"));

Before Switching to iframe (let's say abc), iframes above abc were printed which is correct. But after switching, it prints the same iframes. But actually there are different iframes inside the 'abc' iframe. So after switching to abc, it should print iframes which are only inside abc or along with abc iframes.

I didn't get any NoSuchFrameException while switching which makes it clear that I have switched to the Iframe.

IFrames doesnot have id, class, name attributes, but src.

But When I print the PageSource of abc iframe, it prints only the html source of abc iframe.

String pagesrc = driver.switchTo()

Funny, the same code works in Chrome and FF.

Configuration: IEDriverServer: 3.12.0 IEBrowser: IE9 Jar : Selenium 3.4.0 JDK : 1.8

Html Source: Source

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.