Reputation: 23
I am new to using Robot Framework. I want to accomplish the following: I'm writing an automated test case for a web application. In the application, there is a calendar from which I want to pick a date that is a day in the future from the current date. It is dynamic since the current date is relative to the date when the code will run. Any idea of what I can use?
I had two thoughts in mind, one: to select the current date which would highlight the day on the calendar and then use "Press Keys" to press the right arrow and then Enter which would select the next day of the current date second: to use the DateTime library to determine the current date and somehow to add 1 to the current date which would move the date a day in the future.
I'm not sure if any of my thoughts are doable. any help?
Upvotes: 2
Views: 2036
Reputation: 108
The easiest way is with the DateTime library you can do that this way:
${current_date}= Get Current Date
${date}= Add Time To Date ${current_date} 1 days
This will add up 1 day to the current date
Upvotes: 1
Reputation: 1062
It is doable, have done it once using DateTime
library by adding x days to today. That was the easiest part. The trickiest part was to choose the date around month change, as there might be more than one 30,31,1,2 dates visible. Had to make a an xpath
locator which excluded dates from wrong months.
For instance, in this calendar case, there are two dates with number 24, 25, 26, 28, 29, 1, 2, 3, 4 and 5, so you need to exclude the dates in your locator which belong to wrong month.
Upvotes: 0
Reputation: 6935
I assume, this step to select a date is the prerequisite of what you actually want to test (if it was the main test, then those two ways should be tested). If so, then I would pick the most stable/robust way to do it because you just don't want it to fail.
From what you describe, the first method seems to have more select/click than the second, so I would go for the second method using DateTime library and a single date selection in your app.
Upvotes: 0