Pega Date Picker field to be automated with Java Script code
I do have a Date Picker field where i need to select some past dates in my RPA automation. For that i got 3 Java script codes to select
To check whether the codes were working, i tried it in the Google Chrome console screen by opening my application. Only the selectDate code was working. Month and Year code breaks. Please refer to the attached file "Error.zip".
In addition, I have also attached the html code highlighted after Inspect Element done on the Month/Year. Please refer screenshot "Inspect_Element.zip"
P.S - Also attached the Java script codes and the image of the Date Picker field.
Below are scenario's that you will be facing the attached Errors:
Error-1: Cannot read property 'innerHTML' of null:
I hope you are opening the console and pasting the script and then executing the method "selectMonth(6)" and then you are facing the error. You will be facing this issue when you are not executing on the right page. Below is the sample screen which shows that you are on the right page that the script need to be executed without any errors.
You need to select the right page from the dropdown, then execute the minified script and then invoke the method. You can use inspect tool(blue box in screenshot) to inspect the month element, which will auto-select right page to execute the script. Generally you can see default page as "top" on which datepicker page will not be available and hence you are facing the issue.
Above error you will not be facing, when you use execute and invoke scripts from Robotics, when you use parent webpage of the interrogated date control.
Error 2: Cannot read property 'click' of undefined:
Generally this error occurs in your case when there is no "input" tag present inside "nextYear" or "previousYear" tag. To explain as per user visibility, from below screenshot, when you invoke selectYear(xxxx), this method will click either of the arrows(marked in circle) and reach to the right value, so while executing the method, either of the arrows were not present and hence you are facing the issue.
So we need to check before clicking, I have modified the code accordingly and have attached to this comment. With attached code you will not face this issue but you may need to verify/modify different test cases as per your application requirement as this is a sample code.
Hope this Helps, please let me know if still issue persists.
Even when am at the right page the Year and Month script was not working. When i ran Year script no results returned. Application hanged. With Month script got the same error that i shared initially. Attached recent screenshot of script results for your reference