Selenium Web driver wait for long time

这一生的挚爱 提交于 2019-12-05 01:24:59

问题


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.


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/14893781/selenium-web-driver-wait-for-long-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!