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)
//*[@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).