Send keys and clear text not works in android


#1

Issues: Send keys not works in android

Issues Description:
I have been stuck with this issue for a few days now.
I am executing a script which has to type some text in a text box present in the screen.
Whenever the sendKeys() command with value like 1234567 is executed, it enters 12456 in the screen or sometimes does not type anything in the text box. It behave random every time and not enter exact data which I expect.
Also I face issue with clear text it’s not working properly it takes more time to clear or some time it’s not clearing all data present in textbox.
Tapping on the textbox works perfectly fine.
Below are the configuration I used at the time of execution:
Appium version: 1.10.0 / 1.12.0
Android version: 8.0 / 7.1
Device: Google Pixel / Samsung Galaxy S8
Application Developed: Kony (Hybrid Application)

Below the ways I used to resolve this issue:

  1. JavaScript executor used to send value in textbox/texfield

driver.executeScript(“document.getElementById(’#numtext’).setAttribute(‘value’, 123)”);

  1. Sendkeys()

driver.FindElement(By.Class(“textbox”)).SendKeys(“euiwt8947”);

  1. setText()

object.setText(String.valueOf(e.Age()));

  1. PressKeyCode

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_0);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_1);

  1. getKeyboard()
    driver.getKeyboard().sendKeys(“1”);
    driver.getKeyboard().sendKeys(“2”);

Please revert me back how can I resolve this issue.

Thanks,
Vishal


#2

Please try to help me on above issue. I’m stuck since long time it will good if any buddy resolve this issue


#3

Try:

  1. first tap on field
  2. in while loop with some limiting counter = e.g. 3 clear field. Clear -> get text of field -> with empty do break no luck try again with increase counter. It happens sometimes clear not working perfectly
  3. after clear you may send text
  4. double check default keyboard on device should NOT be some custom.