0

I am trying to find some elements, from a web page which is continuously refreshing for 4 seconds periodically. So when I am trying to detect some of the page elements after parsing the web page,it is throwing exception as :

"org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM".

As the page is getting refreshed periodically,the DOM is getting changed. I can parse only few elements which is located at the upper portion of the DOM structure, because as the page is getting refreshed the internal DOM parser may not able to go inside after certain depth. So in this situation I am not able to traverse the whole DOM,won't able to fetch the lower portion of the DOM.

So please guys kindly,give me a solution so that I can parse the whole page,can traverse the entire DOM tree.

Thanks in advance,

Jerry
  • 7,863
  • 2
  • 26
  • 35
Harry Potter
  • 1
  • 1
  • 7

1 Answers1

0

I dont understand why you need to identify the elements in webpage if the page is getting refreshed continuously as you wont be able to perform any operation on it. Nevertheless, try the following code to get the body tag to a WebElement object:-

WebElement body = driver.getElement(By.tagname("body"))

Use this body object to find the rest of the elements.

body.findElements(By.tagname("input"));
StrikerVillain
  • 3,719
  • 2
  • 24
  • 41
  • Note that the `body` element will also go stale when the page is next refreshed. – Faiz Apr 02 '14 at 00:39
  • Yes, that is the characteristics of the web page. I need to extract the elements from it. If the page is static then it is very easy to parse the page. But handling a web page which is refreshing periodically,is the challenge. – Harry Potter Apr 02 '14 at 10:26