Getting error while using method "driver.hide_keyboard"

Hi

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 = Appium::Driver.new(desired_caps).start_driver
puts "Class of driver is : "+$driver.class.to_s
$driver.find_element(:id, "<id_of_input_field>").send_keys("test")
$driver.hide_keyboard

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

hide_keyboard(‘Finished’)

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

$driver.navigate().back()

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

I am looking for solution on

$driver.hide_keyboard
$driver.hide_keyboard('Finished')

Don’t Know if there is any bug.

Shreyas,

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

http://appium.github.io/java-client/io/appium/java_client/AppiumDriver.html#hideKeyboard()

Hi UD,

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

Hi,
Even you can hide keyboard by clicking on back button also…
driver.sendKeyEvent(AndroidKeyCode.BACK);

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.