Skip to content

Commit 16ea945

Browse files
Fix hide keyboard on iOS
Fix #65
1 parent ad9263c commit 16ea945

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/appium_lib/ios/patch.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,21 @@ def patch_webdriver_element
99
# Cross platform way of entering text into a textfield
1010
def type text
1111
# enter text then tap window to hide the keyboard.
12+
=begin
13+
Find the top left corner of the keyboard and move up 10 pixels (origin.y - 10)
14+
now swipe down until the end of the window - 10 pixels.
15+
-10 to ensure we're not going outside the window bounds.
16+
17+
Swiping inside the keyboard will not dismiss it.
18+
=end
1219
js = <<-JS
1320
au.getElement('#{self.ref}').setValue('#{text}');
14-
au.lookup('window')[0].tap();
21+
22+
if (au.mainApp.keyboard().type() !== "UIAElementNil") {
23+
var startY = au.mainApp.keyboard().rect().origin.y - 10;
24+
var endY = au.mainWindow.rect().size.height - 10;
25+
au.flickApp(0, startY, 0, endY);
26+
}
1527
JS
1628
@driver.execute_script js
1729
end

0 commit comments

Comments
 (0)