Datepicker_issue

Hello There,

I have a date picker in my web. The date picker has today’s date chosen by default.
I do not want the date picker to have today’s date so i have created a keyword for it to take 30 days later date.
My issue is that when i click on that datepicker it automatically add today’s date in the field with the date i have chosen in my keyword.
date

Is there a way i can handle this without having to deal with the default date.
Please do let me know in case more info is needed.

Thanks

@anuradha

Do you also see the same effect when you interact with website outside of Katalon Recorder ? Is this the behavior of the date picker when clicking on a date other than the default date ?

@ThanhTo, Yes it works fine when interacting without katalon recorder. When i will click on the date field by default it will put today’s date in the field and when i click on any other date in the datepicker, it display it correctly.

@anuradha

Please provide the test script and your keyword’s implementation.

Did you click on the date picker after using your own keyword. How abut clicking on it first and then using ClearText on the input, and then use your keyword ?

@ThanhTo

This i have done but the issue is that whenever the set Text part comes for it to take the date it put both today and the date i have selected in the field.
When it moves to the next field it keeps today’s date in the field.
The problem is that whenever i click on the field to add the date, it add today’s date automatically.Even after clearing the text when it clicks on the text field it add today’s date by default.

This is my script for this part:
FuturDate = CustomKeywords.‘essentials.getFutureDate.returnDate’()
WebUI.focus(findTestObject(‘Generic Test Object/12.0 tO/DateFinExercice’))
WebUI.click(findTestObject(‘Generic Test Object/12.0 tO/DateFinExercice’))
WebUI.clearText(findTestObject(‘Generic Test Object/12.0 tO/DateFinExercice’))
WebUI.setText(findTestObject(‘Generic Test Object/12.0 tO/DateFinExercice’),FuturDate)

This is the keyword:
def returnDate(){
SimpleDateFormat dateFormat = new SimpleDateFormat(“dd/MM/yyyy”)
Date date =new Date().plus (30)
String currentDate = dateFormat.format(date.getTime());
return currentDate;
}
}

This is the html:


xath of DateFinExercice: (//input[@type=‘text’])[7]

@anuradha

Is the Click necessary at all, could it be that it causes the default date to be appended automatically ? Try without the click. You should try to put a delay of 2 seconds between each action to make sure nothing weird happens.

@ThanhTo , if i remove the click the same happens. It still take today’s date:
First it does 10/08/202010/09/2020
then when it lets 10/08/2020 stay on the date field.

@anuradha

Please try to use sendKeys to see if the default value is still appended. If you can give me an example of a page with a similar date picker (and behavior when automated with Katalon), it would be a great help !