How to go back or hide the keyboard

How to go back or hide the keyboard after typing in one text field On iOS ?? I tried using driver.hideKeyboard() but doesn’t works with Appium 1.2.1 Please help

2 Likes

Have you tried to update to Appium 1.2.3?

On https://discuss.appium.io/t/appium-server-v1-2-3-released/560

.: fix hideKeyboard bugs

I will try with new release. Thanks for quick reply :smile:

@Nischal_Sinha @Telmo_Cardoso

Neither of methods hideKeyboard or hide_Keyboard are working as getting below error

for #Selenium::WebDriver::Driver:0x007fabd1957250 (NoMethodError)

But as per documentation on ruby_lib/docs/android_docs.md at master · appium/ruby_lib · GitHub

Where do you refer to , in order to find correct method name ?

I’m using Ruby

Thanks,
Vikram

hide_keyboard works for me (in lower case)

1 Like

@Telmo_Cardoso

sorry my bad , I need to wait for keyboard to first appear and then call this method, also I did mistake with method name as well.

do you have any sample project with ruby on github ( with common actions on android / iOS ) which I can refer to for learning good practices ?

Thanks again.

Regards,
Vikram

If someone stumbles upon this thread , please refer to

1> https://github.com/appium/ruby_lib/tree/master/android_tests
2> https://github.com/appium/ruby_lib/tree/master/ios_tests

for sample projects in Ruby.

Regards,
Vikram

There’s also this known issue in the Ruby bindings. Should be a simple fix if someone wants to submit a pull request.

Hi,
I am using Cucumber+Page-Object+Appium and this is the script :
caps = { :browserName => browser_name, :platform => “Android” }
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 500
@browser = Selenium::WebDriver.for(:remote, :url => “http://localhost:4723/wd/hub/”, :http_client => client, :desired_capabilities => caps)
I need to hide/close the Android device key-pad due to which some cases are failing.
How to do it in ruby. Kindly help me out.

using hide keyboard method is available in Android driver.
driver.hideKeyboard();

its working fine when keypad is in enable state some times the keypad in not in enable
it gives error…

I just dont bother too see if its open or not :slight_smile:

public static void hideKeyboard(AppiumDriver driver) throws Exception {
    try {
        driver.hideKeyboard();
    } catch (Exception e) {
        //Lets ignore, apparently its throwing exception when keyboard was not opened
    }
}

But if you really need it, check @auto-geek answer in here (I tried it and it works perfectly):

minor correction:

public void hideKeyboard_Android(AppiumDriver driver) {
    if (((AndroidDriver) driver).isKeyboardShown()) {
        try {driver.hideKeyboard();} catch (Exception e) {}
    }
}
2 Likes