How to use .setText from AppiumDriver instead of .sendKeys from WendDriver or AndroidDriver?

As I am facing problem with slowness of sendKeys method in WebDriver while entering data into text fields on Android UI(on both Simulator and Real Device)…

Please Suggest some alternative ways to insert values into text fields.

Thanks,
Ajit.

You can make text insertion faster by setting sendKeyStrategy to either “grouped” or “setValue” or alternatively cast your WebElement to MobileElement and call setValue method

1 Like

Can you please send code snippet for the same. :blush:

Currently I am using ::
webDrvr.findElement(By.id(“com.xxx.xxx:id/samleGoalEditText”)).clear();
webDrvr.findElement(By.id(“com.xxx.xxx:id/samleGoalEditText”)).sendKeys(“1600”);

I need to follow same lines of code for many other text field components which takes too much time. :frowning:

I am using Selenium WebDriver and Appium.

Please Help.
Thanks,
-Ajit

Try this instead:

((MobileElement) webDrvr.findElement(By.id(“com.xxx.xxx:id/samleGoalEditText”))).setValue(“1600”)

Hello vladisx,
Here is my code::
webDrvr.findElement(By.id(“com.xxx.xxx:id/sampleEditText”)).clear();
((MobileElement) webDrvr.findElement(By.id(“com.xxx.xxx:id/sampleEditText”))).setValue(“7”);
((AndroidDriver)webDrvr).hideKeyboard();

I am getting Error As::
On Eclipse====> Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information).

On Cnosole=====> Responding to a Client that a Method is not implemented.

…And I think ERROR is At SECOND Line… :frowning:
Please Help ASAP.

Thanks,
Ajit.

Sorry, I was wrong - setValue it’s iOS only function and it’s not implemented for Android according to this issue https://github.com/appium/appium/issues/4107

:sleepy:

ohk…Dude…NP.

Thanks for your Time… :blush:

I use a combination of clear and type. e.g.

element = find_element(:id, ID)
element.clear
element.type data

It’s relatively zippy

Is there “.type()” method available in any of Driver class out of WebDriver,AppiumDriver,AndroidDriver.

BTW I am actually facing problem of slowness with sendKeys method to enter text.

Please Help.
Thanks,
Ajit.

In Python you can try this: ‘set_value’ is really helpful, tested and working in iOS

element = self.driver.find_element(*CreateanAccountLocators._FIRST_NAME_ID)
element.set_value('abc')

I use appium only with page source code and for Android and Ios devices.

To edit text, I apply click action (with touchAction) on targeted edit text and after I use directly Driver sendKeys option :
Driver.getKeyboard().sendKeys("")

PS: the Driver is = “AppiumDriver<MobileElement>.”

Dear All,

When i am using .sendkeys in appium it triggers “paste” as well. Can anyone please help me the workaround for this. I am getting stuck due to this.

Regards,
Faizan Farooq Mamji

Thank you…It’s working

I am facing problem in sendkeys where appium is not responding the function of sendkeys instead it is performing click and the keyboard is getting pop up on the text field element

MobileElement email = driver.findElement(By. id (“ID”));

email.sendKeys(“ABC”);

Thread. sleep (1000);

Is there any method to get the keys as return for the validation purpose that are sent through input ?