Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Tech Solutions
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • E-Commerce Demo Application
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

Selenium Automation Testing

  • Introduction to Automation Testing
  • Introduction to Selenium
  • Advantages and Disadvantages of Selenium WebDriver
  • Locators in Selenium
  • How to launch the browsers ? 
  • Browser Navigation Commands in Selenium
  • Handling the textbox and button using selenium
  • Handling the radio button and checkbox using selenium
  • Handling the drop downs and multi-select dropdown
  • Validate the text validation and attributes values. 
  • Handling Images
  • Handling Mouse Events
  • Handling Keyboard Events
  • Handling Alert Popup
  • Handling iFrames
  • Handling Multiple Browsers or Tabs
  • Types of wait statement in selenium
  • How to take screenshots?
  • How to upload File in Selenium?
  • How to handle scroll function using JavaScriptExecutor?
  • How to handle basic functionality using JavaScriptExecutor?
  • How to handle advanced functionality using JavaScriptExecutor?
  • How to automate CAPTCHA?
  • How to handle cookies in selenium
View Categories
  • Home
  • Tutorials
  • Selenium Automation
  • Selenium Automation Testing
  • Types of wait statement in selenium

Types of wait statement in selenium

Types of wait statement in selenium

In Selenium WebDriver, waits are crucial for synchronizing your test automation scripts with the web application’s behavior. There are three main types of waits in Selenium:

1. Implicit Wait

  • Purpose: Tells WebDriver to poll the DOM for a certain time when trying to find any element (or elements) if they are not immediately available.
  • Scope: Applies globally for the WebDriver instance.
  • Syntax (Java):
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

Notes:

  • Once set, it’s applied for the entire life of the WebDriver instance.
  • Not recommended for dynamic and complex UIs as it may cause unnecessary delays.

Use when:

  • Your application is generally stable and all elements load at a predictable speed.
  • You want a simple, global wait for all element searches.
  • You’re writing small, simple test scripts.

Example Scenarios:

  • Static websites where all elements load at once.
  • Quick demos or POCs where you don’t want to add many waits.

2. Explicit Wait

  • Purpose: Waits for a certain condition to occur before proceeding further in the code.
  • Scope: Applied only to specified elements/conditions.

Syntax (Java):

import org.openqa.selenium.support.ui.WebDriverWait;

import org.openqa.selenium.support.ui.ExpectedConditions;

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("myElement")));

Usage Examples:

  • Wait until element is visible/clickable/present.
  • Wait for title, alerts, URLs, text, etc.

Use when:

  • Elements load dynamically or with AJAX calls.
  • You need to wait for a specific condition (visibility, clickable, text present, etc.).
  • The timing for certain elements is unpredictable.

Example Scenarios:

  • Waiting for a login button to become clickable after entering credentials.
  • Waiting for a success message to appear after form submission.
  • Waiting for a loading spinner to disappear.
  • Waiting for an element’s text to change after an action.

3. Fluent Wait

  • Purpose: Similar to explicit wait, but gives more flexibility (polling frequency, ignoring exceptions).
  • Syntax (Java):
import org.openqa.selenium.support.ui.FluentWait;

FluentWait<WebDriver> wait = new FluentWait<>(driver)

    .withTimeout(Duration.ofSeconds(30))

    .pollingEvery(Duration.ofSeconds(2))

    .ignoring(NoSuchElementException.class);

WebElement element = wait.until(driver -> driver.findElement(By.id("myElement")));

Usage:

  • When you need to customize polling intervals and exception handling.

Use when:

  • Elements appear after a variable amount of time.
  • You want to customize polling interval and ignore certain exceptions (like NoSuchElementException).
  • The web page is highly dynamic (e.g., single-page applications, dashboards).
  • Retrying logic is needed before failing.

Example Scenarios:

  • Waiting for a price to update on a stock ticker.
  • Waiting for a chart or graph to load on a dashboard.
  • Handling slow or flaky network responses where elements may appear intermittently.

Summary Table

Wait TypeApplied ToUse CaseExample Syntax
ImplicitAll element searchesDefault wait for all findsimplicitlyWait(Duration.ofSeconds(10))
ExplicitSpecific conditionWait for condition on an element or valueWebDriverWait + ExpectedConditions
FluentSpecific conditionFine-tune polling, exception handlingFluentWait + pollingEvery + ignoring

Note:  

Thread.sleep()

  • Not recommended for automation (static wait).
  • Example: Thread.sleep(2000); pauses for 2 seconds, regardless of page state.

Not recommended except for debugging or in rare cases (like demo, showing the UI, or initial waits before starting a test).

Best Practice:

Use explicit or fluent waits for most real-world web automation. Reserve implicit wait only for simple scenarios.

Selenium Automation Testing
What are your Feelings
Share This Article :
  • Facebook
  • X
  • LinkedIn
Handling Multiple Browsers or TabsHow to take screenshots?
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105