Appium 1.6.4 Send Keys() not working for Android 7.0 - "android.widget.FrameLayout"

Hi All,

I am new to Mobile Automation.
Currently I am using Appium 1.6.4 and Android 7.0 (Samsung Galaxy Edge S7)

Below is my code snippet.

public void enterPIN(){
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
String strPIN = dataTable.getData(“RegisterUser_Data”, “PIN”).trim();
try{
if (isElementPresent(NativeLogin.txtPin0)) {
driver.findElementById(“com.homeserve.androidapp:id/digit0”).sendKeys(“1234”);
report.updateTestLog(“Enter PIN”, “PIN has been entered successfully”, Status.PASS);
}
else{
report.updateTestLog(“Enter PIN”,“PIN has not been entered successfully”, Status.FAIL);
}
}
catch(Exception e){
e.printStackTrace();
}
}

Before upgrading Appium and Android the above code worked fine… means the Sendkeys worked fine.

Once upgrading all softwares, the sendkeys are executed, but actually no values are inputted to the field.

I tried

  1. click() and Sendkeys() together,
  2. tab and sendkeys
  3. JavascriptExecutor

None of the worked. Kindly let me know the solutions if any.

Attached the Screenshot of the page captured in appium inspector.

Note: For the same app in iOS device, the same line of code is working fine.

@Joekannan you should not sendKey to element but press on keyboard instead

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

All,

I verified in Android 6.0.1 (Nexus Tab) also. Sendkeys are not working. Really worried, where is the problem.
Your Timely help is much appreciated. Thanks in advance.

Please let me know in case of additional details.

sendKey should NOT work with your element which is NOT input or let say wheel selection.
you need sendKeycode with keyboard!
to send 1,2,3,4:

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_1);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_2);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_3);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_4);

Thanks for your response. I couldn’t use the above solution, as I am getting “can not cast from CraftDriver to AndroidDriver”, when I use the above code in my framework.

When I use

driver.getKeyboard().sendKeys(“1234”);, only one char is sitting in the first box, if i give

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

by next line, all the char given in all the lines are sitting only on the first box.

really worried as it worked previously fine.

Thanks for your response. the given solution is working fine as a standalone… Have to implement it in my framework.

@Aleksei,

Bit curious to know, how enters in First field etccc… We are not associating any element with input fields right?

How exactly pressKeyCode works here? Is it that we needs to first click on first input field and then pressKeyCode enters value and move to the next field here?

Incase if i have to enter two letters in each input field how it work? Ex: entering out debit card grid in the field.

Hi,

I didnt click on first field etcc… though all the 4 fields have unique id, i didnt mention it anywhere to click and pressKeyCode. Simply I added the below four line, fortunately it worked.

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_1);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_2);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_3);
((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_4);

Thanks for your timely help.

The above instructions are working, but pressKeyCode is deprecated in io.appium 6.1.0.

I’m using io.appium 6.1.0, selenium 3.13.0 and guava 24.0-jre.