![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the different types of wait available in Selenium?
The different types wait available in Selenium are listed below −
Implicit wait
This is one of dynamic waits in Selenium with the Syntax as −
driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
Explicit wait
This is one of dynamic waits in Selenium with the Syntax as −
WebDriverWait w = new WebDriverWait(driver,); w.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("<<xpath expression>>")));
Fluent wait
This is one of dynamic waits in Selenium with the Syntax as −
Wait<WebDriver> w = new FluentWait<WebDriver>(driver).withTimeout(Duration.ofSeconds(30)) .pollingEvery(Duration.ofSeconds(3)).ignoring(NoSuchElementException.class);
Static wait
This is used to pause the execution for a specified amount of time.
Example
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.util.List; public class ThreadWait { public static void main(String[] args) throws InterruptedException { long start = System.currentTimeMillis(); // pause the execution 1 seconds Thread.sleep(1000); long startaftersleep = System.currentTimeMillis(); System.out.println("Sleep time in ms = "+ startaftersleep - start); } }
Advertisements