In Android, my app has a search field which returns values on entering text. I am not able to automate using key events. Any help?
What have you tried so far, and what version of Appium server/appium library are you using? Testing on real devices or emulators?
What happens when you use mySearchField.sendKeys("foo")
?
If that doesn’t work for you, you can always go the painful route of focusing the field with a mySearchField.click()
event and then use a series of driver.sendKeyEvent(int androidKeyCode)
to manually send characters to the field.
The list of android key codes is here:
http://developer.android.com/reference/android/view/KeyEvent.html
Thanks,
Hank
I have tried Android Key Events for Return. When the keyevent is passed, the Done button on Android Keyboard is changing to Return type and nothing is happening from there on.
I am testing on Emulator. I tried on 1.2.4.1 and 1.2.1.1 Appium versions
Thanks
Jagadees
If your application is showing a “Done” button instead of an “Enter” button, you may need to send the keycode for Enter with the FLAG_EDITOR_ACTION metastate - driver.sendKeyEvent(66,16)
. The android Key Event documentation I linked above lists the available metastate flags.
Thanks,
Hank