How to use wait in selenium java

+3 votes
I am new to selenium and am trying to make the browser wait till the user input is fed to the text box. How can I do that? Can someone help me please?
Dec 18, 2018 in Selenium by Anjali
• 2,950 points
770 views

1 answer to this question.

+2 votes

There are different types of wait you can use :

Waits in selenium 

You can use implicit wait like this:

System.setProperty("webdriver.chrome.driver","Your\\path\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(TimeOut, TimeUnit.SECONDS);

You can also explicit wait like this :

System.setProperty("webdriver.chrome.driver","Your\\path\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(WebDriverRefrence,TimeOut)

You can use the following methods to wait that is basically used to put you thread to sleep and also causes an Interrupted Exception so in order to handle the exception we use:

public static void main(String[] args) throws InterruptedException 
{
     System.setProperty("webdriver.chrome.driver","Your\\path\\chromedriver.exe");
     WebDriver driver = new ChromeDriver();
     driver.get("https://www.google.com");//Open google
     Thread.sleep(5000);// here time is in miliseconds so 5000 is 5 second and it will wait 5 seconds
     driver.close();//close the browser
}


Hope this helps.

answered Dec 18, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 29, 2018 in Selenium by bug_seeker
• 15,510 points
1,957 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
8,407 views
+1 vote
1 answer

How to perform mouse hovering in Selenium WebDriver (Java)?

You many not actually be able to ...READ MORE

answered Apr 3, 2018 in Selenium by nsv999
• 5,500 points

edited Aug 22, 2023 by Khan Sarfaraz 10,825 views
0 votes
1 answer

How to use Actions class in Selenium Webdriver?

In seleniun webdriver it is not mandatory ...READ MORE

answered Apr 4, 2018 in Selenium by Damon Salvatore
• 5,980 points
4,092 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,773 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,188 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,263 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,902 views
0 votes
1 answer

How to use css selector in selenium using Java?

Hello @Jino, CSS Selector is pretty easy to ...READ MORE

answered Dec 21, 2018 in Selenium by Nabarupa
1,312 views
0 votes
1 answer

How to use Implicit wait in selenium?

There are various types of wait in ...READ MORE

answered Dec 24, 2018 in Selenium by Nabarupa
725 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP