Getting error while using method "driver.hide_keyboard"


I am using Appium_lib version appium_lib-6.0.0 and appium version 1.3.4
Following is my test code with file name Appium_hide_keyboard.rb

require 'selenium-webdriver'
require 'appium_lib'

desired_caps = {
  caps:       {
  platformName: "android",
  versionNumber: "4.4",
  deviceName: "Samsung_S4",
  app: "C:/Users/Shreyas/Desktop/my_app.apk" 

$driver =
puts "Class of driver is : "+$driver.class.to_s
$driver.find_element(:id, "<id_of_input_field>").send_keys("test")

when I run above code I am getting following output with error

C:\Users\Shreyas\Desktop>ruby Appium_hide_keyboard.rb
Class of driver is : Selenium::WebDriver::Driver
C:/Ruby193/lib/ruby/gems/1.9.1/gems/appium_lib-6.0.0/lib/appium_lib/device/device.rb:194:in  `hide_keyboard': undefined method `device_is_android?' for #<Selenium::WebDriver::Driver:0x42580d2a   browser=:Android> (NoMethodError)
from Appium_hide_keyboard.rb:16:in `<main>'

Can Someone help me ?

Did you try with calling method with parenthesis.

Try following code


Hi Umar,

I tried using hide_keyboard(‘Finished’) still I am getting same error

In appium_lib there is file device.rb line no.48-54 gives following info.

# @!method hide_keyboard
#   Hide the onscreen keyboard
#   @param close_key (String) the name of the key which closes the keyboard.
#     Defaults to 'Done'.
#  ```ruby
#  hide_keyboard # Close a keyboard with the 'Done' button
#  hide_keyboard('Finished') # Close a keyboard with the 'Finished' button

My keyboard niter have ‘Done’ nor ‘Finished’ button


Above code helps me to hide keyboard by pressing back button of device.

I am looking for solution on


Don’t Know if there is any bug.


Did you checked the help document at below location and didnt helped?

Hi UD,

I am able to hide keyboard using java. I am finding solution in ruby.

Even you can hide keyboard by clicking on back button also…

Hi Bhaskar,
I think driver.sendKeyEvent(AndroidKeyCode.BACK); will work in java but not in ruby

Can you please send the snapshot of keyboard that you want to hide and what device and Android OS version you are testing on?

Hi All,

Got exact solution please refer link.