Skip to main content

Use the keyboard keys while automating Android apps

  1. At the top of your test script, add the following script to import the following libraries:
    import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

    import io.appium.java_client.android.AndroidDriver
    import io.appium.java_client.android.nativekey.AndroidKey
    import io.appium.java_client.android.nativekey.KeyEvent
  2. Use this code to access the keys. AndroidKey is an enum with key entries like AndroidKey.ENTER and AndroidKey.A. For example:
    AndroidDriver<?> driver = MobileDriverFactory.getDriver()
    driver.pressKey(new KeyEvent(AndroidKey.ENTER))

    For a complete list of keys, refer to the java-client 6.1.0 API documentation: Enum AndroidKey.

Was this page helpful?