Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Web driver wait for long time

Can I wait with Selenium Web Driver for a long time period?

Even though I can set implicitlywait command like below, it doesn't wait the time that I've given.

 driver.manage().timeouts().implicitlyWait(5, TimeUnit.MINUTES);

Is there anything wrong here?

In my case, I need to execute one test case and wait for 4 minutes and then execute the next test case.

I use Java here.

like image 249
kushan Avatar asked Dec 09 '22 17:12

kushan


1 Answers

Considering you need to wait for a particular element i'd do something in the lines of a ExplicitWait like below.

WebDriverWait wait = new WebDriverWait(driver, 300); // The int here is the maximum time in seconds the element can wait.
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someId")));

On this case you can use any of the ExpectedConditions you'd like. Also not having to use a big wait time on some very particular cases. This imho is a good practice.

like image 78
aimbire Avatar answered Dec 22 '22 02:12

aimbire