In a test I have to automate, I have to fill out a time drop down selection. The catch is that I have to select a time that is 1 hour after the test has created the event. My question is simply:

Is there a method in selenium that can actively get the current time of the test run?

Can I use that data to pick the correct time from the drop down?

If anyone has any suggestion on this matter I would be greatly appreciative.


2 Answers 2


Selenium does not deal with current or future time. But the language you use to write selenium test does. Selenium is just one of the libraries available in your language of choice. Date/time library (and other libraries) are imported in the same way Selenium/webdriver is.


For your specific case, I would try the following:


You add an hour to the current time (and date). Then, you convert it to the format you want for later use in your datepicker. As an alternative to Now you can use some other properties like Hour and Minute if that suits your datepicker input better.

See the DateTime documentation for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.