Cannot select date from DatePicker Dialog Android

Hello, i have a problem, i can’t select a date from calendar dialog (date picker dialog android)

but i can tap, next, and ok button at calendar dialog, i dont know why i can’t select date,

Screen Shot 2018-11-15 at 14.55.18.png

Screen Shot 2018-11-15 at 14.42.04.png

photo_2018-11-15_14-43-39.jpg

Hi, did you manage to get a solution for this? I’m also stuck

Hi @maina.eric,

Could you please share what the Test Object looks like for the date you’re trying to tap? I’m wondering if the properties are too generic so it’s not able to find the specific element you want.

Could you also share any errors you’re seeing in the console log?

Thanks,

Chris

1 Like

Hi @Chris_Trevarthen,

Thanks for the response. See the three screenshots below

image

Hi @maina.eric,

I’ve found that with Android date pickers, I can usually set the date on the text field directly without having to interact with the spinner. You could use the MobileBuiltInKeywords.setText() function or MobileBuiltInKeywords.sendKeys().

If it’s important to interact with the spinner for your tests, then it gets a little trickier with scrolling. You could try using an open source library I work on to make it a bit easier, specifically, you could check out the section on Using a TextField with a Picker List

To include the library in your project, you can check out the “Installation” section.

Hope this helps,

Chris

Hi @Chris_Trevarthen,

Thanks for the response.

Unfortunately `MobileBuiltInKeywords.setText() is not working. Katalon IDE just freezes and does not throw any error as shown below.

Below is a screenshot of the properties of the object we are trying to set text on.

MobileBuiltInKeywords.sendKeys() too doesn’t work

Hi @maina.eric,

Here’s a couple more things we could try:

Another try at MobileBuiltInKeywords.sendKeys()

In your test, make sure you tap on the text field for the date. Then try to use MobileBuiltInKeywords.sendKeys("06/04/2019") to see if it changes the date in the field. You might need to play around with the text a bit in case it breaks on the “/”.

Log what’s on the screen

I’m curious what Katalon and Appium think are on the screen at the time the date dropdown is open. If you want to see some more detail about exactly what Appium/Katalon detects on the screen you can log out the XML contents of the screen. You should be able to do that by putting the following import statements at the top of your test case:

import com.kms.katalon.core.logging.KeywordLogger
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver

Then in the code for your test, add the following right after you drop down the date picker:

AppiumDriver<?> driver = MobileDriverFactory.getDriver()
KeywordLogger log = new KeywordLogger()
log.logInfo(driver.getPageSource())

When the test runs, you should see an entry in the Log Viewer for “Statement - log.logInfo(driver.getPageSource())” that shows the start of the XML for the screen. If you tap on it, you’ll see all of the XML for the screen on the right-hand pane.

If you could attach that XML in a reply that would be helpful for troubleshooting.

It would also be very helpful if you could share your Katalon test script code.

Using a third party library to work with the drop-down

Drop-downs in mobile testing are tricky, so I created an open source library to do a lot of the work for us.

You could try setting the drop-down value using this utility, specifically the Using a TextField with a Picker List section.

In this way, you could set the value of the text field with something like:

TextField.selectOption(dateToField, ['September', '12', '2019'], '9/12/2019', timeout)

For info on how to add the library to your Katalon project, see “Installation”.

Hope this helps,

Chris

Hi @Chris_Trevarthen,

The first option did not work.

Attached below is the xml

katalon xml.txt (34.7 KB)

Also find the test case code

katalon date selector test case.txt (1.5 KB)

Thanks for that info @maina.eric!

Is that XML output when the drop-down/spinner is open? I don’t see any views in there that look like the contents of the spinner. If not, could you also include the screen XML contents after the line:

Mobile.tap(findTestObject('Full Statement/android.view.View47'), 5)

– Chris

how to automate spinner date picker in mobile katalon studio.
Can you help me?
I cannot set date spinner date Picker with android mobile katalon studio.

@Chris_Trevarthen

Hi, I want to automate the spinner date picker. I tried with ScrollToText but it’s not working for the date that is not visible in the spinner date picker dialog box.
@kazurayam

@innayaimran786

Do you really need to interact with the spinner date picker? Do you want to test that component?

I guess you don’t. I suppose, you just want to set a text “20 Oct 2021” into the “Date of birth” field in the page. Then you should be able to set a text into the field by setText() keyword or sendKeys() keyword. See for example

If you really want to debug the spinner date picker, I am not capable to support you as I have very little experience about Mobile testing. Make a search for “date picker mobile” in this forum. You will find a lot of previous posts, especially the posts by @Chris_Trevarthen would help.

At least, “ScrollToText” keyword will not be effective at all. No element in the page is labelled with a text “20 Oct 2021”. You are tricked by the magical Date Picker :mage: