How can I write the keywod for date picker


I need the keyword for date picker even if it change infuture

Have you tried:

'Set text on textbox control'
Mobile.setText(findTestObject('DueDate'),'11/05/2022', 10)

or

Date todaysDate = new Date();
formattedDate = todaysDate.format("MM/dd/yyyy");

'Set text on textbox control'
Mobile.setText(findTestObject('DueDate'), "${formattedDate}", 10)

[Mobile] Set Text | Katalon Docs

1 Like

//*[@class = ‘android.view.View’ and (contains(@text, ‘November 5, 2022’) or contains(., ‘November 5, 2022’))]

it’s xpath is this how can I write the keyword in dynamic way

In your image in first question, you do not have any date in the “Due Date” text box. Therefore, you have no text of any kind to “find” and your “xpath” will not work. It wouldn’t matter if the date was dynamic–you don’t have any date.

You need to understand the difference between getting a pathway to identify the mobile element and entering a “dynamic” date into that element. How to create a “dynamic” date I have given you. Now, you need to get a pathway to the mobile element. Once you get a pathway to the mobile element, then you can enter the current date, whatever the current date is (the date will calculate as being the current one every time the code is run).

Maybe the pathway might be as simple as:
//*[@class = 'android.view.View']

So, putting things together, maybe:

Date todaysDate = new Date();
formattedDate = todaysDate.format("MM/dd/yyyy");

xpath = "//*[@class = 'android.view.View']"
TestObject dueDate = new TestObject()
dueDate.addProperty("xpath", ConditionType.EQUALS, xpath)

'Set text on textbox control'
Mobile.setText(dueDate, formattedDate, 10)

You will need to add some import statements at the top of your Test Case, perhaps using CTRL + SHIFT + O (oh).

1 Like