Usama Zafar
Usama Zafar

Reputation: 1

selenium java wait for page to load completely

Application under test do have its own loading bar so when a element is clicked from main page while applications loading bar is not complete a new page opens but upon application loading loading bar completion it navigates me back to main page.

I tried:

1- Page loading strategy as Normal via chrome Options library.

2-

Boolean ready=  js.executeScript("return document.readyState").equals("complete");
   if(ready){
       wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@mattooltip='Rules']//span[1]"))).click();
       System.out.println(ready);
   }
   else {
       Thread.sleep(10000);
   }

Boolean value returns true however, Application own loading bar does not loads completely yet and page reloads back to main page.I want loading bar to complete and then click element or if application navigates to next page it should not move back to previous page and do the next actions.

Note: Loading bar disappears after loading i am unable to locate loader element.

Upvotes: 0

Views: 69

Answers (0)

Related Questions