user2983190
user2983190

Reputation:

How to change date in datepicker using Appium

I'm trying to change the date in a datepicker element using appium. I can't use the findElement(By.id("id"); since I'm running in version 4.2.2(API 17) and as far as i know By.id is not supported in this version. Using selendroid i can change the date like this:

driver.findElement(By.id("MONTH")).sendKeys("FEB");

In my code in appium I try to access it by the default date. For example im trying to change the month like this:

driver.findElement(By.name("Dec")).sendKeys("Jan");

It seems that although it finds the name Dec it can't send the keys Jan.

Here is the error from the Failure Trace:

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

Any ides on how i can change it and generally if i can use somehow the findElement(By.id("id"); in this API version? Thanks!!

Upvotes: 2

Views: 5549

Answers (1)

user2983190
user2983190

Reputation:

Instead of using the By.name i used By.className in order to change the month the day and the year. Here is my code:

List<WebElement> date = driver.findElements(By.className("android.widget.NumberPicker"));
    date.get(0).sendKeys("Apr");
    date.get(1).sendKeys("17");
    date.get(2).sendKeys("1972"); 

Upvotes: 1

Related Questions