How to set datepicker with current date

How can I set current date in datepicker with JavaScript or anything, I try like this but doesn’t work
Script :
use(TimeCategory, {
var today = new Date()
})
println ("today – " + today.format(‘dd/MM/yyyy’))

WebElement element = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/TC.05/TC.05.7 Surat Perintah/Form/sd’),30)
WebUI.executeJavaScript(‘arguments[0].value=today;’, Arrays.asList(element))

you can create a keyword and then call it in the test case where you will use it.

I use a simple method to insert the text in a date field. A calendar GUI appears when I do, so I click on another area of the page to have the calendar disappear. Since I use my date throughout the Test Suite, I use a Global Variable to hold it (them).

Date todaysDate = new Date();
GlobalVariable.gFormattedDate = todaysDate.format("M/d/yyyy");
GlobalVariable.gScreenFormattedDate = todaysDate.format("MM/dd/yyyy");
GlobalVariable.gLastWeekDate = todaysDate.plus(-7).format("MM/dd/yyyy");
GlobalVariable.gFutureDate = todaysDate.plus(3).format("MM/dd/yyyy");

"date of initial inquiry"
WebUI.setText(findTestObject('myPage/input_GeneralInfo.DateInitialInquiry'),
	GlobalVariable.gScreenFormattedDate)
"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", GlobalVariable.gScreenFormattedDate, 10)

Hi @grylion54, I’ve tried this method but found an error like this :

Ok @anuradha, I will search how to use custom keyword

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)

Here is some information on Global Variables if you should ever need them.

thanks a lot @grylion54, Datepicker already set with currentdate,
Step :

  1. Remove html attribute ‘readonly’
  2. set currentdate as you recommend

yes I will