Sha256: 34affa93f09c9d8e99d19e95eef35718c54e878b32d2fbbc82d00c143acfb7cc

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Calabash
  module Android
    module TextHelpers
      def has_text?(text)
        !query("* {text CONTAINS[c] '#{text}'}").empty?
      end

      def assert_text(text, should_find = true)
        raise "Text \"#{text}\" was #{should_find ? 'not ' : ''}found." if has_text?(text) ^ should_find

        true
      end

      def keyboard_enter_text(text, options = {})
        perform_action('keyboard_enter_text', text)
      end

      def keyboard_enter_char(character, options = {})
        keyboard_enter_text(character[0,1], options)
      end

      def enter_text(uiquery, text, options = {})
        tap_when_element_exists(uiquery, options)
        sleep 0.5
        keyboard_enter_text(text, options)
      end

      def clear_text_in(query_string, options={})
        unless query_string.nil?
          touch(query_string, options)
          sleep 0.5
        end

        clear_text(options)
      end

      def clear_text(options={})
        perform_action('clear_text')
      end

      def escape_quotes(str)
        str.gsub("'", "\\\\'")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calabash-android-0.5.3 lib/calabash-android/text_helpers.rb