Cant see a function like sendKEyEvent in eclipse

Hi , I am trying to use driver.sendKeyEvent(AndroidKeyCode.KEYCODE_MENU) but driver doesnt show any function sendKeyEvent.
Heres my driver initialisation.
private AppiumDriver driver;

Hi,

it’s just a wild guess, but there was a change in the java-client 3.2 saying:

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

Is that maybe the reason ? If so, the methods won’t be in visible when you create a AppiumDriver anyway. You need to create a AndroidDriver.

1 Like

Hi Pradeep,

Use “driver.pressKeyCode(AndroidKeyCode.KEYCODE_MENU)” instead of driver.sendKeyEvent(AndroidKeyCode.KEYCODE_MENU)

Because sendKeyEvent() has been replaced by pressKeyCode() in java-client 3.2

Hope this resolves your issue :wink:

Regards
@Abdul_Sathar_Beigh

1 Like

Yes to increase readability function sendKeyEvent is changed to pressKeyCode although function input , output and return parameters are same

1 Like

Thanks All,
It worked