Hide keyboard strategy

Hi

I’v seen that there exists for ios strategies on how to close keyboard, such as:

pressKey
swipeDown
tapOutside

But this is for java lib

Was this implemented in ruby API?

Because hide_keyboard is returning:

pry(main)> hide_keyboard
post /execute
{
    :script => "!au.mainApp().keyboard().isNil()"
}
post /execute
{
    :script => "if (!au.mainApp().keyboard().isNil()) {\n        var key = au.mainApp().keyboard().buttons()['Done']\n        if (key.isNil()) {\n          var startY = au.mainApp().keyboard().rect().origin.y - 10;\n          var endY = au.mainWindow().rect().size.height - 10;\n          au.flickApp(0, startY, 0, endY);\n        } else {\n          key.tap();\n        }\n        au.delay(1000);\n      }"
}
post /execute
{
    :script => "au.mainApp().keyboard().isNil()"
}
post /execute
{
    :script => "au.mainApp().keyboard().isNil()"
}
post /execute
{
    :script => "au.mainApp().keyboard().isNil()"
}
post /execute
{
    :script => "au.mainApp().keyboard().isNil()"
}
post /execute
{
    :script => "au.mainApp().keyboard().isNil()"
}
Selenium::WebDriver::Error::TimeOutError: timed out after 5 seconds
from /Users/wcs_mac/.rvm/gems/ruby-2.1.2/gems/appium_lib-4.1.0/lib/appium_lib/common/wait.rb:51:in `_generic_wait'

I would like to use something like: hide_keyboard ‘tap_outside’

Thx

I agree. The ruby bindings need to be updated. I’ve opened a ticket.

module PlatformsCommonModule

def type *args
find_element(args[0],args[1]).send_keys(args[2])
if ENV[‘PNAME’] == ‘android’
$driver.hide_keyboard
else
dismiss_keyboard = (<<-JS).strip
if (!au.mainApp().keyboard().isNil()) {
var onePixelAboveKeyboard = au.mainApp().keyboard().rect().origin.y - 1
UIATarget.localTarget().tap({x:0, y:onePixelAboveKeyboard});
}
JS
execute_script dismiss_keyboard
end
end

end

World(PlatformsCommonModule)