How to select date from date picker?

Hi
I am not able to select date in katalon
I tried following the instructions, but no luck

Please help.



Instead of using the date picker GUI to select your date, can you just use, WebUI.setText(findTestObject('the date textbox'), "12/25/2022")

Now I just used a String for a static date, however, you can calculate a date, such as:

def todaysDate = new Date().format("MM/dd/yyyy")
WebUI.setText(findTestObject('the date textbox'), todaysDate)

And if you want even more complicated dates, like 6 months from now, you can use SimpleDateFormat or Calendar libraries to create them. There are other examples using them on this forum too.

Just note that I have to click on something that is not beneath (overlaid by) the date GUI in order for it to disappear after I set the date into the textbox, such as the accompanying label or another textbox or textarea above the date GUI.

1 Like

I tried and it didn’t work.

And…what happened? Did you get an error message? Did you get nothing displayed?

Testcase still passed but date doesn’t change

Is there a date in the Date GUI before you start? Can you remove any beforehand date with:

WebUI.clearText(findTestObject('the date textbox'))
WebUI.setText(findTestObject('the date textbox'), "12/25/2022")
WebUI.sendKeys(findTestObject('the date textbox'), Keys.chord(Keys.TAB))

I also note that you have an <iframe> just above the code you show above. Is the date textbox within the <iframe>? If it is, you have to “switchToFrame” before you can set any text.

Testcase still passed but date doesn’t change. This field can not remove data.

Can we have a look at this field and the Date Picker GUI?

date picker
Here you are

When you put in the “Start date”, do you have to enter the time as well? Also, the X at the end of the “Start date”, does that clear the date to enter another?

The field shows both the date and time, the X to clear the data.

Can you do an experiment with the setText() we have above but before using it, you clear any date in the field (if there is) with the X and see if that does anything? If you have to enter a time along with the date, then do that as well with the same setText(), like:

WebUI.click(indTestObject('the X button'))
WebUI.setText(findTestObject('the date textbox'), "12/25/2022, 09:00")

I don’t know why when this button step fails. I have taken the source code to include in the selected locator but it also failed.

Can you right click on the “Start date” textbox and select “Inspect” (do this twice)? The HTML code for the “Start date” should display. Can you display the HTML for the “Start date”? From the HTML, we can formulate a pathway for the element.

Also, note that you have SVG in your xpath, so the below may be of interest.

@phanuyend

Is the URL of your target web page public? Is is possible for us to open the URL in the browser of on our side? If so please share the URL.

@phanuyend

Your question is dependent on the structure of the HTML source. Therefore we need to be able to open it in browser in hand to see the HTML source code and study in detail.

HTML source code matters! Please understand this.

If you can not share the live URL and username/password for security reason, please save the target page (after login) into a MIME HTML file, and share the file here. The following post tells you how to save a web page into a MIME HTML file.

The credentials (username/password) will not be included in the MHT file. So you need not be worrried about the security.

Provided with the saved HTML shared, others will be able to open the HTML in their own browser and look at the HTML structure precisely. Then somebody would be able to give you some productive advices.

Please show how your “Object Repository/Page_feedbackonline - Task System/path start date” is defined. Please take the screenshot of the definition and show it here.

Sorry, it’s the company’s own website, I can’t make it public

Feedbackonline.mht (49.2 KB)

here you are