Sha256: 8cb54e387692348f11eec8d84069aa2c6467f8a2e6c43223581e6e6ecb6c8a77

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
module Appium::Ios
  # class_eval inside a method because class Selenium::WebDriver::Element
  # will trigger as soon as the file is required. in contrast a method
  # will trigger only when invoked.
  def patch_webdriver_element
    Selenium::WebDriver::Element.class_eval do
      # Cross platform way of entering text into a textfield
      def type text
        # enter text then tap window to hide the keyboard.
        js = <<-JS
          au.getElement('#{self.ref}').setValue('#{text}');
          au.lookup('window')[0].tap();
        JS
        @driver.execute_script js
      end

      # returns if the element is visible
      # 1 = visible
      # 0 = not visible
      # null = unknown
      # http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIAElementClassReference/UIAElement/UIAElement.html#//apple_ref/doc/uid/TP40009903
      def visible
        js = <<-JS
          au.getElement('#{self.ref}').isVisible();
        JS
        @driver.execute_script js
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appium_lib-0.3.14 lib/appium_lib/ios/patch.rb