Module: Calabash::Android::TextHelpers
- Included in:
- Operations
- Defined in:
- lib/calabash-android/text_helpers.rb
Instance Method Summary collapse
- #assert_text(text, should_find = true) ⇒ Object
- #clear_text(query_string, options = {}) ⇒ Object
- #enter_text(uiquery, text, options = {}) ⇒ Object
- #escape_quotes(str) ⇒ Object
- #has_text?(text) ⇒ Boolean
- #keyboard_enter_char(character, options = {}) ⇒ Object
- #keyboard_enter_text(text, options = {}) ⇒ Object
Instance Method Details
#assert_text(text, should_find = true) ⇒ Object
8 9 10 11 12 |
# File 'lib/calabash-android/text_helpers.rb', line 8 def assert_text(text, should_find = true) raise "Text \"#{text}\" was #{should_find ? 'not ' : ''}found." if has_text?(text) ^ should_find true end |
#clear_text(query_string, options = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/calabash-android/text_helpers.rb', line 28 def clear_text(query_string, ={}) result = query(query_string, setText: '') raise "No elements found. Query: #{query_string}" if result.empty? true end |
#enter_text(uiquery, text, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/calabash-android/text_helpers.rb', line 22 def enter_text(uiquery, text, = {}) tap_when_element_exists(uiquery, ) sleep 0.5 keyboard_enter_text(text, ) end |
#escape_quotes(str) ⇒ Object
36 37 38 |
# File 'lib/calabash-android/text_helpers.rb', line 36 def escape_quotes(str) str.gsub("'", "\\\\'") end |
#has_text?(text) ⇒ Boolean
4 5 6 |
# File 'lib/calabash-android/text_helpers.rb', line 4 def has_text?(text) !query("* {text CONTAINS[c] '#{text}'}").empty? end |
#keyboard_enter_char(character, options = {}) ⇒ Object
18 19 20 |
# File 'lib/calabash-android/text_helpers.rb', line 18 def keyboard_enter_char(character, = {}) keyboard_enter_text(character[0,1], ) end |
#keyboard_enter_text(text, options = {}) ⇒ Object
14 15 16 |
# File 'lib/calabash-android/text_helpers.rb', line 14 def keyboard_enter_text(text, = {}) perform_action('keyboard_enter_text', text) end |