Appium java client 3.3.0 - pressKeyCode() not supported for selendroid mode?

Hey All,

I am using appium selendroid mode to test our android app, and want to use the new pressKeyCode(int key) method…

but turns out it is not working. Is it because it is selendroid mode, so it is not working? is there any other alternative way to do the same?

error info:

  • org.openqa.selenium.WebDriverException: ERROR running Appium command: req.device.pressKeyCode is not a function

according to release note in version 3.2.0

  • Replace sendKeyEvent() method in android with pressKeyCode(int key) and added: pressKeyCode(int key, Integer metastate), longPressKeyCode(int key), longPressKeyCode(int key, Integer metastate)

if u r running tests under selendroid mode, then u need to maintain functions supported by selendroid driver. obvious reason why it is failing because all above listed functions uses uiautomator instrumentation which will not work with selendroid. find relevant documentation on selendroid.io

Thanks for ur suggestions. I am now using below code to do the same action, and it works

new Actions(driver).sendKeys(SelendroidKeys.MENU).perform();

2 Likes