Selecting date from date picker field

Not able to automate datepicker field to select the date.

I have my testdata in excelsheet and is linked with Katalon project. I’m not able set the needed date in datepicker field.

‘Set Text’ doesn’t work, because the field is not editable manually. You can only select a date through datepicker.

Please help me to resolve this issue. I have attached the screenshot.

Picture1.png

Hi Saranya,

You can try this project: https://github.com/katalon-studio/katalon-web-automation. This project has a custom keyword to handle date picker: https://github.com/katalon-studio/katalon-web-automation/blob/master/Keywords/reusableComponents/DatepickerHandler.groovy and you can use it as a solution to work with your calendar :slight_smile:

Can anyone provide with instructions on how to build / use that project? Thanks!

hi i am not able to automate date picker field to select the date can some one help on this issues

Hi Vinh Nguyen /Team,

I am unable to access both links

(https://github.com/katalon-studio/katalon-web-automation
https://github.com/katalon-studio/katalon-web-automation/blob/master/Keywords/reusableComponents/DatepickerHandler.groovy).

Is there any way, where i can access the instructions on how to build / use that project?
Also the “custom keyword” to handle date picker.

Please guide me. Awaiting your reply…
Thanks in advance…

Why don’t you use Jquery to set or get value from date-picker??
I gave up on Katalon methods for setting and getting values.
To set value you can do this
$(’#yourElementID’).val(‘09.04.2018’)

In your script you can put this:

WebUI.executeJavaScript((’$("#IdOfDatePicker").val("’ + YourGlobalVariable) + ‘")’, [])

1 Like

Hello, I have the same problem and it is my solution.

WebUI.focus(findTestObject(‘Page_Business Insurance/input_Fecha’))

WebUI.executeJavaScript(’$(\’:input\’).removeAttr(\‘readonly\’)’, [])

WebUI.delay(1)

WebUI.setText(findTestObject(‘Page_Business Insurance/input_Fecha’), ‘01/11/2018’)

WebUI.sendKeys(findTestObject(‘Page_Business Insurance/input_Fecha’), Keys.chord(Keys.ENTER))

1 Like

Luis alberto guzman said:

Hello, I have the same problem and it is my solution.

WebUI.focus(findTestObject(‘Page_Business Insurance/input_Fecha’))

WebUI.executeJavaScript(‘$(\’:input\‘).removeAttr(\‘readonly\’)’, )

WebUI.delay(1)

WebUI.setText(findTestObject(‘Page_Business Insurance/input_Fecha’), ‘01/11/2018’)

WebUI.sendKeys(findTestObject(‘Page_Business Insurance/input_Fecha’), Keys.chord(Keys.ENTER))

Thank you. It works for me !!!

Luis alberto guzman said:

Hello, I have the same problem and it is my solution.

WebUI.focus(findTestObject(‘Page_Business Insurance/input_Fecha’))

WebUI.executeJavaScript(‘$(\’:input\‘).removeAttr(\‘readonly\’)’, )

WebUI.delay(1)

WebUI.setText(findTestObject(‘Page_Business Insurance/input_Fecha’), ‘01/11/2018’)

WebUI.sendKeys(findTestObject(‘Page_Business Insurance/input_Fecha’), Keys.chord(Keys.ENTER))

Hi there,

the Bold line is getting underlined in my script do I need to import something…???

I am automating a mobile app and got this solution… just trying my luck… please help…

thanks in advance

Hi there,

Please add the below 2 packages

import org.apache.commons.lang3.StringUtils

import org.openqa.selenium.Keys as Keys

crokatalontest said:

Why don’t you use Jquery to set or get value from date-picker??
I gave up on Katalon methods for setting and getting values.
To set value you can do this
$(‘#yourElementID’).val(‘09.04.2018’)

In your script you can put this:

WebUI.executeJavaScript((‘$(“#IdOfDatePicker”).val("’ + YourGlobalVariable) + ‘")’, )

HI!
Where can I set de value?

Luis_alberto

why in my katalon not work, but No error in execute javascript.,

and only error in object repository Date picker not found.

.

you are using the attribute “readonly = true” to define your object, when you ejecute the javascript you removed that attribute in the web page and the attribute changed to “readonly = false”.

try to define your object with the Id value litke this.

Thanks a lot, this solution is working for my Date picker for jQuery v4.0.6.

1 Like