Hi Friends,
Appium Version: 1.3.5
Android Device: Nexus 5 , API 21.
I am New to Appium, I have updated my Appium to latest version (1.3.5) and I am able to select proper date from Date Picker in Android device through recording mode. Here is the recorded script below:
(JavascriptExecutor)wd.executeScript(“mobile: scrollTo”, new HashMap<String, String>() {{ put(“element”, wd.findElement(By.xpath("//android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.DatePicker[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.NumberPicker[3]")).getId()); }});
I have copied the above script and pasted in my script which I have written in Eclipse to check whether i am able to select date from Date Picker through this script. I made some small changes in the script. Here is the modified script below:
((RemoteWebDriver) wd).executeScript(“mobile: scrollTo”, new HashMap<String, String>() {{ put(“element”, wd.findElement(By.xpath("//android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.DatePicker[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.NumberPicker[3]")).getId()); }});
Here i am facing a problem about getId() method, when I am placing my mouse cursor on getId() method it is saying: The method getId() is undefined for the type WebElement.
OLD Version
In Appium Old version I have written a script to pick date from Date Picker
List date = wd.findElements(By.className(“android.widget.NumberPicker”));
date.get(0).sendKeys(“Feb”);
wd.navigate().back();
date.get(1).sendKeys(“17”);
wd.navigate().back();
date.get(2).sendKeys(“1995”);
wd.navigate().back();
The above script is setting the required data in date picker, but when I am click on OK button in data picker screen, current date is displaying in “Date Of Birth” field.
So please someone help me.