Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard in Android physical device isn’t always hidden while using Appium

When I want to hide the keyboard, (because if I don't hide it when I click into a button under keyboard a number from keyboard is pressed instead of the confirm button for example) some times it's hidden ok by the command driver.hidekeyboard(); and other times it's hidden automatically.

Other times it tells me

An unknown server-side error occurred while processing the command. (Original error: Soft keyboard not present, cannot hide keyboard)

like image 659
Emna Ayadi Avatar asked Jan 22 '16 09:01

Emna Ayadi


1 Answers

Use adb command to check whether keyboard has popped up or not

adb shell dumpsys input_method | grep mInputShown 

Output : mShowRequested=true mShowExplicitlyRequested=false mShowForced=false mInputShown=true

if mInputShown=true then yes software keyboard has popped up. Then use driver.pressKeyCode(AndroidKeyCode.BACK);

PS: Please do not use driver.navigate().back() as its behavior may not be same on all devices.

like image 85
Chandrashekhar Swami Avatar answered Oct 13 '22 22:10

Chandrashekhar Swami