WebDriverException: Message: Unknown mobile command "pressKey"

Hi everyone, I am using robot framework, specifically AppiumLibrary library to test android application, however when I use keyword “Press Keycode” the following error message, help me to fix this error:

WebDriverException: Message: Unknown mobile command “pressKey”. Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogs,Info gettroadcast,stopaccept DeviceTime,changePermissions,getPermissions,performEditorAction ,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,deleteFile,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks commands are supported.
Stacktrace:
UnknownCommandError: Unknown mobile command “pressKey”. Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogs,Info gettroadcast,stopaccept DeviceTime,changePermissions,getPermissions,performEditorAction ,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,deleteFile,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks commands are supported.
at AndroidUiautomator2Driver.executeMobile (C:\Users\toannv\Downloads\A…
[ Message content over the limit has been removed. ]
…ules\appium\node_modules\appium-base-driver\lib\baseddriver\driver.js:335:9)
at C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\async-lock\lib\index.js:146:12
at AsyncLock._promiseTry (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\async-lock\lib\index.js:280:31)
at exec (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\async-lock\lib\index.js:145:9)
at AsyncLock.acquire (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\async-lock\lib\index.js:162:3)
at AndroidUiautomator2Driver.executeCommand (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\baseddriver\driver.js: 348:39)
at AppiumDriver.executeCommand (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\lib\appium.js:563:36)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at asyncHandler (C:\Users\toannv\Downloads\Appium-Server-GUI-windows-1.22.0\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:297: 21)

Hi Taon,

Bear in mind I don’t use AppiumLibrary myself so this is just a guess.

i see keywords Is Keyboard Shown and Hide Keyboard but not a Show Keyboard, it might be worth calling Is Keyboard Shown before Press Keycode to see if the keyboard is active, perhaps you can’t send keystrokes when the keyboard is hidden?

That would be what I would try first, so I hope that helps,

Dave.

Hi Damies13,

Thanks for your answer, I tried it but it didn’t work.

I think it has something to do with Webdriver but I don’t know how to deal with it yet.

1 Like

Hi Taon, have you had any solution for this issue? I have the exact same one and I don’t know how to fix it!

Thank you
Nathalie

hi

It would be worth sharing the statement it self from code for how you’ve structured and have the keyword/args

Thanks.