[英]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. 我正在尝试从一个网页中查找一些元素,该网页会定期不断刷新4秒。 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. 由于页面会定期刷新,因此DOM
也正在更改。 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. 我只能解析位于DOM结构上部的少量元素,因为随着页面的刷新,内部DOM解析器可能无法在一定深度后进入内部。 So in this situation I am not able to traverse the whole DOM,won't able to fetch the lower portion of the DOM . 因此,在这种情况下, 我将无法遍历整个DOM,也无法获取DOM的下部 。
So please guys kindly,give me a solution so that I can parse the whole page,can traverse the entire DOM tree. 因此,请大家给我一个解决方案,以便我可以解析整个页面,可以遍历整个DOM树。
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:- 尽管如此,请尝试以下代码将body标签获取到WebElement对象:
WebElement body = driver.getElement(By.tagname("body"))
Use this body object to find the rest of the elements. 使用此主体对象查找其余元素。
body.findElements(By.tagname("input"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.