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.
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 :
Syntax : driver.manage().timeouts().implicitlyWait(time period, TimeUnit.SECONDS);
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.
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.
document.readyState === 'complete'
posible results for .readyState function are as follows one of five values, representing the status of the current document:
- uninitialized - Has not started loading yet
- loading - Is loading
- loaded - Has been loaded
- interactive - Has loaded enough and the user can interact with it
- 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