I have written custom code to access keyboard
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.getKeyboard().sendKeys(Keys.RETURN)
But its not working.
I have written custom code to access keyboard
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.getKeyboard().sendKeys(Keys.RETURN)
But its not working.
Should be like this:
driver.pressKeyCode(AndroidKeyCode.BACK);
There is an AndroidKeyCode for the ENTER key as well, so this should work:
AndroidDriver<?> driver = MobileDriverFactory.getDriver()driver.pressKeyCode(AndroidKeyCode.ENTER)
I am not adept at writing code or able to edit the script. I have a similar issue as above where I need to hit the enter key on the android keyboard but I am not able to when I do the spy mobile. In the manual script view how would I add items or objects so that after entering a name in the search bar the script knows to invoke enter command.

Hi Darlene,
Unfortunately, I donât know a way to hit the Android Enter button using Test Recorder or Spy Mobile, either.
However, if you want to use the âManualâ view to create and edit your test, you can still add the Enter button handling I mentioned above:
1. Click the down arrow next to âAddâ and choose âBinary Statementâ
2. This will insert a new row in the test with Item âBinary Statementâ and âInputâ of â0 == 0â
3. Double click the â0 == 0â value
4. Youâll see a new window with the individual values. Fill in the values like this:

5. Click OK
6. Click the down arrow next to âAddâ and choose âMethod Call Statementâ
7. This will insert a new row in the test with Item âMethod Call Statementâ and âInputâ of âtoString()â
8. Double click the âtoString()â value
9. Youâll see a new window with the individual values. Fill in the values like this:

10. Click OK
11. You should now see 2 lines in your test like this:

12. Use the Move Up/Move Down buttons to put them in the right order for your test.
This should add Enter button pressing into your Android Katalon test!
Hope this help,
Chris Trevarthen
Screen Shot 2018-08-26 at 11.00.35 PM.png
Ok thank you
Hi,
My application is running, I would like to press on overview button and then close the application. Please do let me know how do I do this, Katalon recoder or Spy mobile is not able to recognised the overview button (square button on next home button).
Hi Chris
I have some problem,
i cant press button âSEARCHâ (replace âENTERâ) in keyboard mobile test
I try
AppiumDriver<?>driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.SEARCH))
and
AndroidDriver<?> = MobileDriverFactory.getDriver()
driver.pressKeyCode(AndroidKeyCode.KEYCODE_SEARCH)
but not workâs
can you help me sirr,
my katalon ver 6.2.2 appium 1.8.1
regrards
Putra
Hi Cris,
I have same problem
i canât presskey button âSEARCHâ (replace âENTERâ) from keyboard on mobile testing
i try use
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKeyCode(AndroidKeyCode.KEYCODE_SEARCH)
and
appiumDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.SEARCH))
but not works
can you help me sirr
btw my katalon ver 6.2.2 and appium ver 1.8.1
regrads
Putra
Hi @Putra.Sinantaka,
You could try a slightly longer version of the pressKey() command:
driver.pressKey(new KeyEvent(AndroidKey.ENTER)
.withFlag(KeyEventFlag.SOFT_KEYBOARD)
.withFlag(KeyEventFlag.KEEP_TOUCH_MODE)
.withFlag(KeyEventFlag.EDITOR_ACTION));
Which was mentioned here:
Hope this helps,
Chris
Hi Chris,
yeah, i have try this, but still not working -___-
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.SEARCH)
.withFlag(KeyEventFlag.SOFT_KEYBOARD)
.withFlag(KeyEventFlag.KEEP_TOUCH_MODE)
.withFlag(KeyEventFlag.EDITOR_ACTION))
and
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.ENTER)
.withFlag(KeyEventFlag.SOFT_KEYBOARD)
.withFlag(KeyEventFlag.KEEP_TOUCH_MODE)
.withFlag(KeyEventFlag.EDITOR_ACTION))
regrads
Putra
could you show me step by step to making script for Enter Keys?
Hi @Putra.Sinantaka,
Thatâs interesting. Could you provide some more info about:
Thanks,
Chris
Hi @khadapynurhuda,
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver
import io.appium.java_client.android.nativekey.AndroidKey
import io.appium.java_client.android.nativekey.KeyEvent
import io.appium.java_client.android.nativekey.KeyEventFlag
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.ENTER)
.withFlag(KeyEventFlag.SOFT_KEYBOARD)
.withFlag(KeyEventFlag.KEEP_TOUCH_MODE)
.withFlag(KeyEventFlag.EDITOR_ACTION));
Hope this helps,
Chris
anyway, Iâve used
AndroidDriver<?> driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.SEARCH))
But, I donât know why, in android keyboard, it will tap on âuâ, instead of SEARCH key
Funny, when I tapped âuâ, it works to tap on âuâ:
Hi @khadapynurhuda,
You could also try using an older function called pressKeyCode:
driver.pressKeyCode(66) // ENTER key
or
driver.pressKeyCode(84) // SEARCH key
Hope this helps,
Chris
Hi Chris,
still, it taps on âuâ
my Android version is 5.1.1 (KitKat)
is it related to the script that I used?
A few more things you can try if the pressKey functions arenât working:
Execute an Appium script:
driver.executeScript("mobile:performEditorAction", ImmutableMap.of("action", "done"));
Send a newline character into your current text field:
textFieldElement.sendKeys('\n')
Just hide the keyboard:
driver.hideKeyboard()
â Chris