Selenium Wait for page to load/Element | Selenium Forum
M
Posted on 26/11/2016
Hi Team,

I have tried with all possible wait

implicite wait, explicite wait, java script wait but those ae working for some extents , My aplication is built on javascript and selenium scripts running very fast and i am not able to wait til the element to load.

Please let me know what will be the best approach i can take here.

Thanks
Manoj

M
Replied on 27/11/2016

show me the code of wait statements.


M
Replied on 10/12/2016

1. Implicit wait:
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

2. Javascript wait for the element ready state
((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");

3. Thread.sleep(6000) // this will work irrespective of the page load.

4. WebElement element = (new WebDriverWait(getDriver(), 30)).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input#name")));

//This will through exception if the element is not found

My application is build in angular js, Please suggest me which is the best approach to follow handling synchronisation.

Thanks


M
Replied on 11/12/2016

You can make a custom function customWait()
and call it

public void customWait(String time){
Thread.sleep(time);
}


M
Replied on 12/12/2016

Is there any solution other than thread.sleep?