Skip to content

Commit b611ac6

Browse files
Fix typing on disabled textfield
Fix #86
1 parent d887050 commit b611ac6

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lib/appium_lib/ios/patch.rb

+17-12
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ def type text
1919
# type
2020
$driver.execute_script %(au.getElement('#{self.ref}').setValue('#{text}');)
2121

22-
# wait for keyboard
23-
$driver.wait_true { $driver.execute_script %(au.mainApp.keyboard().type
24-
() !== 'UIAElementNil') }
22+
$driver.ignore {
23+
# wait 5 seconds for keyboard. if the textfield is disabled then
24+
# setValue will work, however the keyboard will never display
25+
# because users are normally not allowed to type into it.
26+
$driver.wait_true(5) do
27+
$driver.execute_script %(au.mainApp.keyboard().type() !== 'UIAElementNil')
28+
end
2529

26-
# dismiss keyboard
27-
js = <<-JS
28-
if (au.mainApp.keyboard().type() !== "UIAElementNil") {
29-
var startY = au.mainApp.keyboard().rect().origin.y - 10;
30-
var endY = au.mainWindow.rect().size.height - 10;
31-
au.flickApp(0, startY, 0, endY);
32-
}
33-
JS
30+
# dismiss keyboard
31+
js = <<-JS
32+
if (au.mainApp.keyboard().type() !== "UIAElementNil") {
33+
var startY = au.mainApp.keyboard().rect().origin.y - 10;
34+
var endY = au.mainWindow.rect().size.height - 10;
35+
au.flickApp(0, startY, 0, endY);
36+
}
37+
JS
3438

35-
$driver.execute_script js
39+
$driver.execute_script js
40+
}
3641
end
3742
end
3843
end

0 commit comments

Comments
 (0)