Because these methods should, in general, do the smallest chunk of work possible.
This is particularly true with the page object model. The idea behind that model is that your classes (Custom Keywords) should simply act as an interface between the script and the application. In other words, the methods should allow the script writer to do everything that a manual user could do; no more, and no less.
Having the method just return the value means that you can reuse that method for other things, not just the problem you are trying to solve for right now.
In either case, you’ve got a good Custom Keyword to work with, so if you’re comfortable with it, no need to change it. You may find in the future that you want to use the month/year value for something else, in which case you can refer back to this post, which may make more sense at that time
I am having a problematic time with a datepicker calendar that I am trying to do some automated testing for. I tried using setText on the input field that is holding the dates, but the datepicker calendar overwrites it with the current date for the From field and the next day for the To field.
Here is a screen shot as to what I am referring to.
Does the date picker gets triggered by the Set Text or its appearance is part of the flow you’re trying to test ? When does the date picker overwrites the text ? The moment you’re done setting text or the moment the date picker is triggered ? Is there a rationale for this behavior, it could be the developer’s mistake
Trying to deal with the calendar, I believe, would have been impossible. Trying to do a setText on the input field wasn’t working because the date picker overwrote my text with the current day and the following day.
This code is working
def driver = DriverFactory.getWebDriver()
Try to enter the date manually and then use the same format as what was entered. Note the date you are getting from your CSV file will be a String, not a Date, so make sure you have the correct data type variable.