How do you dismiss the keyboard in an Appium test on iOS? I get this entry in the console after entering text
[INSTSERVER] Sending command to instruments: if (!au.mainApp().keyboard().isNil()) {
var key = au.mainApp().keyboard().buttons()['Done']
if (key.isNil()) {
var startY = au.mainApp().keyboard().rect().origin.y - 10;
var endY = au.mainWindow().rect().size.height - 10;
au.flickApp(0, startY, 0, endY);
} else {
key.tap();
}
au.delay(1000);
}
I can see it is assuming the button is 'Done' on my keyboard it is 'return'. Looking at the documentation I should be able to do this in the following way https://github.com/appium/ruby_lib/blob/ef20cdd09cdb3dac32b789144b17ed2daf745a8d/docs/ios_docs.md#hide_keyboard
I have tried this using the following code:
When(/^I enter the text "(.*?)"$/) do |user_text|
textfield( "My Textbox" ).type user_text
hide_keyboard( "Return" )
end
Despite this it still hangs looking for the 'Done' button. How do you override which key Appium looks for. I have uploaded a Git repository with my code here: GitHub Repository
When I use 'Done' as the keyboard button to Return it works. Problem is my app doesn't use 'Done'.