0

In my code, I need to press some number and click on green tick button.

enter image description here

After I click, expected is hide the keypad and it shows a error validation message..

enter image description here

I have the following code in my script.

    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.ENTER));

As per code. Its entering the value. Not sure which AndroidKey to pass for pressing Green tick button, I'm passing AndroidKey.ENTER. It gives a different behavior and manually also pressing enter give same behavior.

enter image description here

Can any one tell him how to pass AndroidKey parameter, so it press the green tick key. It's definitely not ENTER.

Ramkumar
  • 116
  • 1
  • 11

3 Answers3

1
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="fintme"
android:inputType="text"
android:imeOptions="actionSend" />

EditText editText = (EditText) findViewById(R.id.edittext);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    boolean handled = false;
    if (actionId == EditorInfo.IME_ACTION_SEND) {
        //yourcode
        handled = true;
    }
    return handled;
  }
});
Dhruv Sakariya
  • 792
  • 4
  • 10
0

I found from other groups below solutions.

driver.executeScript(“mobile: performEditorAction”, ImmutableMap.of(“action”, “Go”));

List of other options supported can be found in below sites: https://developer.android.com/reference/android/view/inputmethod/EditorInfo

https://appium.io/docs/en/writing-running-appium/android/android-ime/

Also, When we have keypad visible, clicking on BACK button also hides the keyboard and it shows the screen.

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.BACK));
Ramkumar
  • 116
  • 1
  • 11
0

Please use valid mobile number of 10 digits as this seems to be get validated on mobile app.

Your script is fine except entering a valid mobile number with your automation script.

Also, please check first manually any valid mobile number and then input the same mobile number with your automation script, this should resolve your issue then.