How to set datepicker with current date

If you are not going to use the formatted date in more than one Test Case, then you can simply change from using GlobalVariables to a simple String variable, like below:

Date todaysDate = new Date();
def screenFormattedDate = todaysDate.format("MM/dd/yyyy");

"date of initial inquiry"
WebUI.setText(findTestObject('myPage/input_GeneralInfo.DateInitialInquiry'),
	screenFormattedDate)
"click on another area of the page to let the calendar GUI disappear"
WebUI.click(findTestObject('myPage/textarea_GeneralInfo.Location'))
"verify the date is set"
WebUI.verifyElementAttributeValue(findTestObject('myPage/input_GeneralInfo.DateInitialInquiry'),
	"value", screenFormattedDate, 10)
1 Like