Skip to content

Commit 7c9e8d0

Browse files
Don't try and hide the keyboard after .type
1 parent 544e34a commit 7c9e8d0

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

lib/appium_lib/ios/helper.rb

+6
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,18 @@ def eles_by_json_visible_exact element, value
379379
# @return [void]
380380
def hide_ios_keyboard close_key='Done'
381381
=begin
382+
todo: there are many various ways to hide the keyboard that work in different
383+
app specific circumstances. webview keyboard will require a window.tap for example.
384+
382385
Find the top left corner of the keyboard and move up 10 pixels (origin.y - 10)
383386
now swipe down until the end of the window - 10 pixels.
384387
-10 to ensure we're not going outside the window bounds.
385388
386389
Swiping inside the keyboard will not dismiss it.
387390
391+
If the 'Done' key exists then that should be pressed to dismiss the keyboard
392+
because swiping to dismiss works only if such key doesn't exist.
393+
388394
Don't use window.tap. See https://github.com/appium/appium-uiauto/issues/28
389395
=end
390396
dismiss_keyboard = (<<-JS).strip

lib/appium_lib/ios/patch.rb

-19
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,8 @@ def label
1414

1515
# Cross platform way of entering text into a textfield
1616
def type text
17-
# enter text then tap window to hide the keyboard.
18-
=begin
19-
Find the top left corner of the keyboard and move up 10 pixels (origin.y - 10)
20-
now swipe down until the end of the window - 10 pixels.
21-
-10 to ensure we're not going outside the window bounds.
22-
23-
Swiping inside the keyboard will not dismiss it.
24-
25-
var startY = au.mainApp().keyboard().rect().origin.y - 10;
26-
var endY = au.mainWindow().rect().size.height - 10;
27-
au.flickApp(0, startY, 0, endY);
28-
29-
The above logic has been accepted as part of appium's au.hideKeyboard
30-
https://github.com/appium/appium-uiauto/blob/dbeb4eedbdea2104751a0d547ac9b2894e0dc567/uiauto/appium/app.js#L902
31-
32-
If the 'Done' key exists then that should be pressed to dismiss the keyboard
33-
because swiping to dismiss works only if such key doesn't exist.
34-
=end
3517
# type
3618
$driver.execute_script %(au.getElement('#{self.ref}').setValue('#{text}');)
37-
$driver.hide_ios_keyboard
3819
end # def type
3920
end # Selenium::WebDriver::Element.class_eval
4021
end # def patch_webdriver_element

0 commit comments

Comments
 (0)