0

In selenium-java, after switching to frame new DOM is appended on existing DOM, when I call findelement method passing xpath of append dom, it is throwing me error staleelementnoreference exception.

Is there any way where identify new DOM is appended or not using selenium/java/javascript? I have used explicit wait to fix staleelementexception, it does not work in IntelliJ(2018.3), but works in eclipse?

Gino
  • 112
  • 1
  • 9
Arun
  • 1

1 Answers1

0

Assuming you are attempting to use Selenium with an iFrame and there is only one iframe on the page:

You must switch to the new frame prior to calling findElement().

DO

driver.switchTo().frame(driver.findElements(By.tagName("iframe")[0]));

To switch back to the main page:

driver.switchTo().defaultContent();
Randy Casburn
  • 13,840
  • 1
  • 16
  • 31
  • Thanks Randy, I am able to switch to new iframe . after switching i need to get text of new DOM appended using findelement method. Do we have any code to cross check new appended DOM loaded or not, bcoz..new appended dom is big in size, getting exception in intellij ,but not in eclipse – Arun Oct 20 '18 at 16:25
  • Yes, use the iFrame's onload handler ( `documents.frames[0].onload = ...` ) – Randy Casburn Oct 20 '18 at 17:21
  • check this: https://stackoverflow.com/questions/29233928/iframe-onload-javascript-event – Randy Casburn Oct 20 '18 at 17:22