Java code
- Public Static boolean Waitpagerefresh (Webelement trigger) {
- int refreshtime = 0;
- Boolean isrefresh = false;
- try {
- For (int i = 1; i < ; i++) {
- Refreshtime = i;
- Trigger.gettagname ();
- Thread.Sleep (1000);
- }
- } catch (Staleelementreferenceexception e) {
- Isrefresh = true;
- System.out.println ("page refresh Time is:" + refreshtime + "seconds!");
- return Isrefresh;
- } catch (Webdriverexception e) {
- E.printstacktrace ();
- } catch (Interruptedexception e) {
- E.printstacktrace ();
- }
- System.out.println ("page didnt refresh in seconds!");
- return Isrefresh;
- }}
Description: Added the staleelementreferenceexception exception starting from Selenium 2.16. Once the page element is refreshed, this exception is thrown when the element is again manipulated. So you can determine whether the page refreshes based on this as the identity. or whether to jump to the next page. Flexibility to set the waiting time. and can count the refresh time.