Sorry for the late response(turned of the notification for this post by mistake)
Here's the snippet i'm using
String command = "adb shell input text \""+newData+"\"";
Process result = Runtime.getRuntime().exec(command);
You can mix and mach these commands whatever fulfills your requirements.
@Priyank_Shah I don't use the integer values i.e. 84 you used. I always pass the string constant android site provided.
adb -s input keyevent KEYCODE_SEARCH
and the key event for the buttons other than the characters don't work always.
I prefer
element.sendKeys(text+"\n")
Indeed that's the simplest way.( What i suggested were workaround as the author of this post was looking for the possible way to actually tap on the key, which is not possible for android)
Yes there aren't any Key code for "Done", to achieve this i usually send enter's key code
Thanks for pointing it out.(Updated the answer.)
No there aren't any specific key code for Done/OK/Next key. For simulating those we need to send the metastate along with the keycode of "Enter" key.
driver.sendKeyEvent(key, metastate);
For sending the Next/Done key metastate code is 16.
If that not working we can send the KEYCODE_DPAD_DOWN (for Next).
And these are just workaround if the thing are not working as expected.
@pr4bh4sh, I got it. Thanks!
@Alex_Bogdanov
Could you please share your code that works? I am facing the same problem. Thanks!
Sorry @Olivia_Ong for so late answer. If it still hasn't solved, could you please explain what actual problem did encounter with key codes?
Any help would be appropriated
I need to click or tap on Go/Done button on android s3 device which running 4.3 version
I tried all sorts of option
1. driver.pressKeyEvent(66) or driver.pressKeyEvent(AndroidKeyCode.ENTER)
2. Driver.sendKeyEvent(66)
3. driver.execute("mobile:keyevent", "keycode:66");
I manage to click on all keys except Go/Done button
Environments
Appium version - 1.4.13
Java 1.7 appium
Maven - 3.2.0
For the Next/Go/Done combination, I use
adb shell input keyevent 'KEYCODE_TAB'
http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_TAB710
Hope this helps
@rakesh Are you using below capability ?capabilities.setCapability("unicodeKeyboard", true);
If not can you try with this capability.
Hi,
capabilities.setCapability("unicodeKeyboard", true) did't worked for me
I asked my developer to add a lister called "OnKeyListener"
finally worked.....
refer to this https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/12
@praveentp009 explained in detail
thanks @praveen
Except what rakesh said in the above thread(as i cannot force developer to write extra code and developers are not accessible for me)
I tried all the ways specified in this thread, but didnt help. Can someone help me here?
element.sendKeys(strValue+"\n"); - entering the value but soon after navigating to home screen.
element.sendKeys(strValue);
String command = "adb -s input keyevent KEYCODE_SEARCH";
** try {**
** Process result = Runtime.getRuntime().exec(command);**
** } catch (IOException e) {**
** // TODO Auto-generated catch block**
** e.printStackTrace();**
** }**
enter the value but didnt click on Search button.
element.sendKeys(strValue);
driver.sendKeyEvent(AndroidKeyCode.ENTER);
Enter the value and bringing back to home screen.
Also tried with Keyevent codes 84 and 66, but didnt help.
Can someone let me know any other soluctions