简体   繁体   中英

How to parse all the elements in Selenium Webdriver using Java for a webpage which is continously refreshing for 4 seconds periodically?

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,

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM