This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 12
Jan 2015

Hello,

I have a problem in setting the date from a date picker in Appium. I'm trying to set the date by sending keys in the fields in this way:

List<WebElement> pick = driver.findElements(By.className("android.widget.EditText"));           

        pick.get(0).sendKeys("21");
        pick.get(1).sendKeys("Mar");
        pick.get(2).sendKeys("1989");

This works fine in previous versions of API but since I'm testing in a different device now appium seems not to finding my elements correctly. Here is a photo from the inspector window that shows that I'm using the correct class to find the fields.enter image description here

Any ideas?Thanks!!

  • created

    Jan '15
  • last reply

    Nov '18
  • 11

    replies

  • 6.2k

    views

  • 10

    users

  • 1

    like

  • 3

    links

18 days later

@Panos Did you find any solution for this problem ?

My app users Google date widget which has same id for month , date and year. ( id: android:id/numberpicker_input )

I tried using send_keys but it's not working as expected.

If you can please share your solution , it'll be helpful

Thanks,
Vikram

11 months later
17 days later

Hi guys, did you find the solution to this issue? I am using appium and I am not able to set the date.

20 days later
2 months later

Check if this53 helps

driver.FindElement(By.Id("com.eos.eos_du_su:id/ed_manufdate")).Click();
((AndroidElement)(driver.FindElement(By.XPath("//android.widget.NumberPicker[@index='0']//android.widget.Button[@index=0]")))).Tap(1, 2);

((AndroidElement)(driver.FindElement(By.XPath("//android.widget.NumberPicker[@index='1']//android.widget.Button[@index=0]")))).Tap(1, 2);

((AndroidElement)(driver.FindElement(By.XPath("//android.widget.NumberPicker[@index='2']//android.widget.Button[@index=0]")))).Tap(1, 2);

driver.FindElement(By.Id("android:id/button1")).Click();
1 month later

Hi Guys, Did anyone get a solution for datepicker issue?
I am working on mobile web application and not able to select the date from android native calendar.

Thanks in advance.

11 months later

Hi.

This is my first reply to someone/something on this forum XP

I will put the code that works for me (in the most simple way in Ruby).

arg1="2016"
picker = find_element(xpath: "//*[@index='2' and @class='android.widget.NumberPicker']")
picker.textfield(1)
picker.send_keys(arg1)

The index=2 is for the "year" part of the date (for that reason arg1="2016"), so you can use index=0 to the day and index=1 do the month part. That works if you have 3 elements with the class android.widget.NumberPicker in the date picker.

I hope it works for you dudes!!

1 year later

sendKeys() is not working for the date picker. Is there anyone who has found a solution for this?

I resolved this the below way in appium-java client:

Android emulator API level: 28
Android emulator version: 9
Appium java client version: 5.0.4

currentMonthElement is the WebElement that represent the month field in the datepicker. you can use the find by xpath or whichever way you like to find this element. The below code can be reused to enter value for date and year elements. In the place of currentMonthElement variable, please pass the date and year elements.

touchAction.longPress(LongPressOptions.longPressOptions().withElement(ElementOption.element(currentMonthElement))).release().perform();
driver.getKeyboard().sendKeys(Keys.DELETE);
String monthstr = “Aug”;

//This while loop is required since sometimes the month “Aug” was not successfully entered at the first attempt.
while(!currentMonthElement.getText().equals(monthstr)){
driver.getKeyboard().sendKeys(“Aug”);
}

//click on the ok button after setting the date, month and year using the above code.
driver.findElement(By.id(“button1”)).click();

3 months later