-1

I need help, I read about in selenium WebDriver wait forever until the website loads but how do I do this ?. I exported my java test but do not understand how to use that option to wait until the page loads or until all the buttons on the page.

2

Basically you can use explicit wait to wait until your specific element of page get visible.

There are 2 types of wait :

1 - Implicit wait

2 - Explicit wait

Examples are given below :

Implicit wait

Syntax : driver.manage().timeouts().implicitlyWait(time period, TimeUnit.SECONDS);

Explicit wait

Syntax : WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("yourelementid")));

Main concept of both wait :

Implicit wait : It tells the web driver to wait for specified time by poll the DOM. Once you declared implicit wait it will be available for the entire life of web driver instance. Default the value will be 0.

Explicit wait : It is the custom wait. It will be used if want the execution to wait for some time until some condition achieved or element visible.

| improve this answer | |
  • 1
    Hola, no entiendo mucho en donde usar este codigo. Yo tengo el complemento en el browser existe algun comando que permita esperar por tiempo ilimitado hasta que el elemento aparezca?. Soy muy nueva esto muchas gracias – Karina Serrano Feb 5 '15 at 13:08
  • No there is nothing to do with that browser plugin for your scenario. you will have to install selenium web driver to your pc and will need to write code using programming language like java to achieve that wait goal. How you can configure all that is given here : guru99.com/installing-selenium-webdriver.html – Helping Hands Feb 6 '15 at 3:53
  • Thank you so much however i don't how to use after the installation, can you help me please, how to use this for rus test – Karina Serrano Feb 6 '15 at 16:23
  • For that you will have to install eclipse , JDK , JRE and selenium web driver JARs to your system. Also it need that you must have basic knowledge of java programming , do you have? – Helping Hands Feb 9 '15 at 3:51
  • Yes i have, i tried and i installed eclipse, jdk, and i followed all steps but when i tried tu run a simple test said me the class web driver don't found. The code is: import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Webdriver_class { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("google.com"); System.out.println(driver.getTitle()); driver.close(); } } – Karina Serrano Feb 9 '15 at 12:48
0

As far as I understand you are talking about pageLoadTimeout Which sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.

Basically page is considered as loaded when this statement (javascript) evaluates as true

document.readyState === 'complete'

posible results for .readyState function are as follows one of five values, representing the status of the current document:

  1. uninitialized - Has not started loading yet
  2. loading - Is loading
  3. loaded - Has been loaded
  4. interactive - Has loaded enough and the user can interact with it
  5. complete - Fully loaded

Implementation AFAIK depends on language, but more generally you can think about page loading as described in official documentation for Java selenium

Load a new web page in the current browser window. This is done using an HTTP GET operation, and the method will block until the load is complete. This will follow redirects issued either by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, since should the underlying page change whilst your test is executing the results of future calls against this interface will be against the freshly loaded page.

Hope that helps in understanding

More info available here, here and here

| improve this answer | |
  • Hola, yo tengo el complemente de selenium instaladado en el browser existe algun comando que me permita esperar por tiempo ilimitado hasta que la pagina carge, en casos donde hay lentitud en la red. Soy nueva en esto – Karina Serrano Feb 5 '15 at 13:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.