Module: Briar::Keyboard
- Defined in:
- lib/briar/keyboard/keyboard.rb
Constant Summary collapse
- UITextAutocapitalizationTypeNone =
0
- UITextAutocapitalizationTypeWords =
1
- UITextAutocapitalizationTypeSentences =
2
- UITextAutocapitalizationTypeAllCharacters =
3
- UITextAutocorrectionTypeYes =
0
- UITextAutocorrectionTypeNo =
1
- UITextSpellCheckingTypeNo =
might be 0 and 1?
1
- UITextSpellCheckingTypeYes =
2
Instance Method Summary collapse
- #auto_correct_type ⇒ Object
-
#autocapitalization_type ⇒ Object
is it possible to find what view the keyboard is responding to?.
-
#briar_clear_text(view_id, timeout = nil) ⇒ Object
noinspection RubyUnusedLocalVariable.
- #briar_keyboard_enter_text(text) ⇒ Object
-
#set_autocapitalization(type) ⇒ Object
noinspection RubyUnusedLocalVariable.
-
#set_autocorrect(type) ⇒ Object
noinspection RubyUnusedLocalVariable.
- #should_not_see_keyboard(timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
- #should_see_keyboard(timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
- #turn_autocapitalization_off ⇒ Object
- #turn_autocorrect_off ⇒ Object
- #turn_spell_correct_off ⇒ Object
Instance Method Details
#auto_correct_type ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/briar/keyboard/keyboard.rb', line 60 def auto_correct_type if !query('textView index:0').empty? query('textView index:0', :autocorrectionType).first.to_i elsif !query('textField index:0').empty? query('textField index:0', :autocorrectionType).first.to_i else screenshot_and_raise 'could not find a text view or text field' end end |
#autocapitalization_type ⇒ Object
is it possible to find what view the keyboard is responding to?
50 51 52 53 54 55 56 57 58 |
# File 'lib/briar/keyboard/keyboard.rb', line 50 def autocapitalization_type if !query('textView index:0').empty? query('textView index:0', :autocapitalizationType).first.to_i elsif !query('textField index:0').empty? query('textField index:0', :autocapitalizationType).first.to_i else screenshot_and_raise 'could not find a text view or text field' end end |
#briar_clear_text(view_id, timeout = nil) ⇒ Object
noinspection RubyUnusedLocalVariable
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/briar/keyboard/keyboard.rb', line 72 def briar_clear_text(view_id, timeout=nil) unless timeout.nil? _deprecated('0.1.1', "will remove 'timeout' argument in a future release", :warn) end clear_text("view marked:'#{view_id}'") # i really wanted this to work, but there are too many issues with the # touch not bringing up the the Select menu bar - for example sometimes # it brings up the typo correction bar. #wait_for_view view_id #step_pause #touch("view marked:'#{view_id}'") #wait_for_button 'Select All', timeout #step_pause #touch_button_and_wait_for_view 'Select All', 'Cut', timeout #step_pause #touch_button 'Cut' #step_pause end |
#briar_keyboard_enter_text(text) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/briar/keyboard/keyboard.rb', line 41 def briar_keyboard_enter_text (text) keyboard_enter_text text # not ideal, but entering text by uia keyboard will never return what # was text was actually input to the keyboard @text_entered_by_keyboard = text end |
#set_autocapitalization(type) ⇒ Object
noinspection RubyUnusedLocalVariable
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/briar/keyboard/keyboard.rb', line 95 def set_autocapitalization (type) _deprecated('0.1.1', 'does not work', :pending) #if !query('textView index:0').empty? # query('textView index:0', [{setAutocapitalizationType: type}]) #elsif !query('textField index:0').empty? # query('textField index:0', [{setAutocapitalizationType: type}]) #else # screenshot_and_raise 'could not find a text view or text field' #end end |
#set_autocorrect(type) ⇒ Object
noinspection RubyUnusedLocalVariable
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/briar/keyboard/keyboard.rb', line 112 def set_autocorrect (type) _deprecated('0.1.1', 'does not work', :pending) #if !query('textView index:0').empty? # query('textView index:0', [{setAutocorrectionType: type}]) #elsif !query('textField index:0').empty? # query('textField index:0', [{setAutocorrectionType: type}]) #else # screenshot_and_raise 'could not find a text view or text field' #end end |
#should_not_see_keyboard(timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/briar/keyboard/keyboard.rb', line 31 def should_not_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT) msg = "waited for '#{timeout}' seconds but keyboard did not disappear" wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do element_does_not_exist 'keyboardAutomatic' end end |
#should_see_keyboard(timeout = BRIAR_WAIT_TIMEOUT) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/briar/keyboard/keyboard.rb', line 21 def should_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT) msg = "waited for '#{timeout}' seconds but did not see keyboard" wait_for(:timeout => timeout, :retry_frequency => BRIAR_WAIT_RETRY_FREQ, :post_timeout => BRIAR_WAIT_STEP_PAUSE, :timeout_message => msg) do element_exists('keyboardAutomatic') end end |
#turn_autocapitalization_off ⇒ Object
106 107 108 109 |
# File 'lib/briar/keyboard/keyboard.rb', line 106 def turn_autocapitalization_off _deprecated('0.1.1', 'does not work', :pending) #set_autocapitalization UITextAutocapitalizationTypeNone end |
#turn_autocorrect_off ⇒ Object
123 124 125 126 |
# File 'lib/briar/keyboard/keyboard.rb', line 123 def turn_autocorrect_off _deprecated('0.1.1', 'does not work', :pending) # set_autocorrect UITextAutocorrectionTypeNo end |
#turn_spell_correct_off ⇒ Object
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/briar/keyboard/keyboard.rb', line 128 def turn_spell_correct_off _deprecated('0.1.1', 'does not work', :pending) #if !query('textView index:0').empty? # query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}]) #elsif !query('textField index:0').empty? # query('textField index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}]) #else # screenshot_and_raise 'could not find a text view or text field' #end end |