Reputation: 1825
I am using Appium 1.4.13, java-client-3.3.0.jar, selenium standalone server 2.48.2 with IntelliJ.
I want to enter a value to UIATextField, which is a numberpicker. I read a tutorial and it suggested:
(MobileElement) iosDriver.findElement(By.xpath("//UIATextField")).sendKeys("abcdef");
but this didn't work: it just opened a native numberpicker from iOS
Another suggestion is to use setValue for java client 2.2.0:
(MobileElement) iosDriver.findElement(By.xpath("//UIATextField")).setValue("abcdef");
But setValue method is not there anymore.
So I have a workaround like below and it works:
(MobileElement) iosDriver.findElement(By.xpath("//UIATextField")).click;
iosDriver.scrollToExact("abcdef");
//click confirm
My questions:
Thanks
This is what I got from Appium Inspector when I run
(MobileElement) iosDriver.findElement(By.xpath("//UIATextField")).sendKeys("170");
Upvotes: 1
Views: 2857
Reputation: 876
I am working on Xamrin app and Appium iOS driver was not able to send keys to UIATextField using @iOSXCUITFindBy.Though on Android same function was working fine.
I modified the function to first make a click and with this I was able to enter username and password in the webview.
public void enterUsername(String userName)
{
this.userName.click();
this.userName.sendKeys(userName);
}
Upvotes: 0
Reputation: 677
setValue changed to be only valid for IOSElement. Cast your element accordingly and it should work.
Ex: (IOSElement) iosDriver.findElement(By.xpath("//UIATextField")).setValue("abcdef");
Upvotes: 1
Reputation: 31878
Your initial code with appium 3.3.0 java-client should work just that your input is slight incorrect. A small note on that, a number picker has a regex defined to get an input of Integer type so you can better try sending it a numeral input. Try this, shall help :
(MobileElement) iosDriver.findElement(By.xpath("//UIATextField")).sendKeys("12"); //sending an integer value
Upvotes: 0