@@ -22,13 +22,23 @@ def type text
2222-10 to ensure we're not going outside the window bounds.
2323
2424Swiping inside the keyboard will not dismiss it.
25+
26+ var startY = au.mainApp().keyboard().rect().origin.y - 10;
27+ var endY = au.mainWindow().rect().size.height - 10;
28+ au.flickApp(0, startY, 0, endY);
29+
30+ The above logic has been accepted as part of appium's au.hideKeyboard
31+ https://github.com/appium/appium-uiauto/blob/dbeb4eedbdea2104751a0d547ac9b2894e0dc567/uiauto/appium/app.js#L902
32+
33+ If the 'Done' key exists then that should be pressed to dismiss the keyboard
34+ because swiping to dismiss works only if such key doesn't exist.
2535=end
2636 # type
2737 $driver. execute_script %(au.getElement('#{ self . ref } ').setValue('#{ text } ');)
2838
2939 $driver. ignore {
30- # wait 5 seconds for keyboard. if the textfield is disabled then
31- # setValue will work, however the keyboard will never display
40+ # wait 5 seconds for a wild keyboard to appear . if the textfield is disabled
41+ # then setValue will work, however the keyboard will never display
3242 # because users are normally not allowed to type into it.
3343 $driver. wait_true ( 5 ) do
3444 $driver. execute_script %(au.mainApp().keyboard().type() !== 'UIAElementNil')
@@ -37,13 +47,16 @@ def type text
3747 # dismiss keyboard
3848 js = <<-JS
3949 if (au.mainApp().keyboard().type() !== "UIAElementNil") {
40- var startY = au.mainApp().keyboard().rect().origin.y - 10;
41- var endY = au.mainWindow().rect().size.height - 10;
42- au.flickApp(0, startY, 0, endY);
50+ au.hideKeyboard('Done');
4351 }
4452 JS
4553
4654 $driver. execute_script js
55+
56+ # wait 5 seconds for keyboard to go away
57+ $driver. wait_true ( 5 ) do
58+ $driver. execute_script %(au.mainApp().keyboard().type() === 'UIAElementNil')
59+ end
4760 }
4861 end # def type
4962 end # Selenium::WebDriver::Element.class_eval
0 commit comments