Domanda

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.

È stato utile?

Soluzione 2

Actually this is not my answer, Two days ago I saw this answer here, But I had no time to apply it.Today I tried it and that's what exact I wanted.

Unfortunately Now I can not see that answer here.So I added this answer and all credits should go to the user who posted this answer here.

In this case what I wanted to do is to wait the driver for 5 mins so that until execute the periodical cron job.

Thread.sleep(4000); to pause execution of program.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top