3

I have a scenario where I login to an application, perform a download operation then wait (stay) on that page for 30 minutes, then again perform the download operation.

Is implicitwait for 30 minutes is feasible in the scenario? Is there any better option?

Ajinkya
  • 22,324
  • 33
  • 110
  • 161
TodayILearned
  • 1,440
  • 4
  • 20
  • 28
  • Could you please clarify why you need to stay on the page for 30 minutes? To have your session expired? – Viktor Malyi May 13 '15 at 07:32
  • tell us why your want to wait or 30 minutes, this doesn't sound like good design in the first place. – Dude May 13 '15 at 07:36
  • @ViktorMalyi This is the requirement of the team. We want to observe for how long page can be kept idle before continuing with the next scenario. – TodayILearned May 13 '15 at 09:18
  • Some sort of setting defines the session time out. Instead of waiting the configured time. Change the setting and test it with a shorter time. These kind of test are other quite bad to run. – Andreas Waldahl May 13 '15 at 14:44

2 Answers2

5

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. It wont be helpful for current scenario.

You can use Thread.sleep or TimeUnit.sleep like

try {
     TimeUnit.MINUTES.sleep(30);
} catch (InterruptedException e) {
    //Handle exception
}

For more information : I'm unable to use Thread.sleep(x) or wait(): java.lang.InterruptedException; must be caught or declared to be thrown

Community
  • 1
  • 1
Ajinkya
  • 22,324
  • 33
  • 110
  • 161
3

You don't have to use the implicit wait. Use Thread.Sleep(30*60*1000); instead. This will sleep the main thread of your tests until the specified value of milliseconds pass.

driver.Navigate().GoToUrl("http://yourapplication.com");
Thread.Sleep(30*60*1000); 
// Download Files
martin
  • 3,149
  • 1
  • 24
  • 35
Anton Angelov
  • 1,705
  • 13
  • 16