top of page

Selenium WebDriver Wait Commands

In automation testing, Selenium WebDriver wait commands direct test execution to pause for a certain length of time before moving onto the next step. Listing out the different WebDriver Wait statements that can be useful for an effective scripting.


Types of Waits in Selenium

1.Implicit Waits

The main function of implicit wait is to tell the web driver to wait for some time before throwing a Exception. We should note that implicit waits will be in place for the entire time the browser is open. This means that any search for elements on the page could take the time the implicit wait is set for.

Syntax:

driver. manage().timeouts().implicitlyWait(TimeOut,TimeUnit.SECONDS);


2.Fluent Wait Command

Fluent Wait in Selenium marks the maximum amount of time for Selenium WebDriver to wait for a certain condition (web element) becomes visible. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.

Syntax:

Wait wait = new FluentWait(driver)

    .withTimeout(30, SECONDS)

    .pollingEvery(5, SECONDS)

    .ignoring(NoSuchElementException.class);

  WebElement foo = wait.until(new Function() {

    public WebElement apply(WebDriver driver) {

    return driver.findElement(By.id("foo"));

3. PageLoadTimeout Command

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.

Syntax:

driver.manage().timeouts().pageLoadTimeout(100, SECONDS);


4.SetScriptTimeout Command

Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.

Syntax:

driver.manage().timeouts().SetScriptTimeout(100, SECONDS);


 
 
 

Recent Posts

See All

Comments


MiIT Logo

Company

Contact Us

+1905-487-4880 

5160 Explorer Dr #34, Mississauga,ON L4W 4T7

+1929-743-3199

4466 Buttonwood Ln Lilburn, GA 30047

262 Chapman Rd, STE 240 Newark DE 19702

+44 20 4525 1214

71-75 Shelton Street, Covent Garden, London, United Kingdom WC2H 9JQ

Stay up to date on the latest from MiIT

  • Instagram
  • Facebook
  • http://linkedin.com/company/miittechnologies/about/
  • Whatsapp

© All Content MiIT Technologies Inc.2019 - 2025. All rights reserved.

bottom of page