0

I am using Appium 3.4.1, Android v4.4.2 with Java for automation testing for Android App. I have got stuck for sending values to editText box which activate numeric keyboard when focusing on field. However, when I clear the field it works, when I click in field it works but when I sendKeys to field it does not work. It type the value to other fields. I have tried all the possible ways based on below links. Also, there are fields on multiple screen which open numeric keyboard when focusing and sendkeys method is working for those field.

Is there any way where we can use the android keyboard to type value in field using Appium

  1. https://discuss.appium.io/t/android-sendkeys-function-clicks-taps-random-elements-in-the-page-but-does-not-enter-text-in-the-edittext-element/2095
  2. https://discuss.appium.io/t/appium-1-3-3-sendkeys-not-working-properly/2074

I would appreciate your inputs on this.

Code :

WebElement element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_work‌​out_add_exercise_MS")); 
element.clear(); 
element.click(); 
element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_work‌​out_add_exercise_MS")); 
element.sendKeys("55");
Naman
  • 27,789
  • 26
  • 218
  • 353
Learner
  • 15
  • 1
  • 7
  • Here are few more links which I have used: 3. https://discuss.appium.io/t/sendkeys-and-click-function-does-not-work-for-ios-simulator/5896 4. http://stackoverflow.com/questions/25529900/sendkeys-fails-on-android-appium-driver 5. https://github.com/appium/appium/issues/4297 – Learner Apr 08 '16 at 08:36
  • could you share the code you've tried as well – Naman Apr 08 '16 at 10:07
  • @nullpointer Thanks for your response!!!! `WebElement element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_workout_add_exercise_MS")); element.clear(); element.click(); element=driver.findElement(By.id("com.intellih.mobile:id/edt_caloriesBurned_workout_add_exercise_MS")); element.sendKeys("55");` – Learner Apr 08 '16 at 17:43
  • what does adding `System.out.println(element.getAttribute("className") )` to your code after `element` is defined display? – Naman Apr 08 '16 at 18:03
  • On console it display `android.widget.EditText` when I run `System.out.println(element.getAttribute("className") )` – Learner Apr 08 '16 at 19:29
  • please add the appium server logs and code to the question in that case – Naman Apr 08 '16 at 19:37
  • you can download the log from here http://s000.tinyupload.com/download.php?file_id=00620222351464733278&t=0062022235146473327869080 – Learner Apr 08 '16 at 20:08

1 Answers1

0

Click on the field and then run below command

Runtime.getRuntime().exec("adb shell input keyevent KEYCODE_NUMPAD_5";

This will type 5 in the field you can run multiple command on same field.

Karim Narsindani
  • 434
  • 3
  • 14
  • 38