Class: UIAutomation::Target

Inherits:
RemoteProxy show all
Defined in:
lib/ui_automation/target.rb

Overview

A RemoteProxy to UIATarget objects in the Javascript API.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemoteProxy

#[], #execute_self, #fetch, from_element_id, from_javascript, #initialize, #inspect, #perform, #proxy_for, #to_javascript, #to_s

Methods included from ElementProxyMethods

#element_array_proxy_for, #element_proxy_for

Constructor Details

This class inherits a constructor from UIAutomation::RemoteProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class UIAutomation::RemoteProxy

Class Method Details

.local_target(executor) ⇒ UIAutomation::Target

Returns an instance of UIAutomation::Target that represents the singleton local target (UIATarget.localTarget()).


10
11
12
# File 'lib/ui_automation/target.rb', line 10

def self.local_target(executor)
  from_javascript(executor, 'UIATarget.localTarget()')
end

Instance Method Details

#front_most_appUIAutomation::Application

Returns a proxy to the currently active app.


17
18
19
# File 'lib/ui_automation/target.rb', line 17

def front_most_app
  proxy_for(:frontMostApp, proxy_klass: UIAutomation::Application)
end

#location=(coordinates) ⇒ void

Sets the current location (iOS Simulator only).

Parameters:

  • coordinates (Hash)

    A hash containing :lat and :lng keys.


24
25
26
# File 'lib/ui_automation/target.rb', line 24

def location=(coordinates)
  set_location(coordinates)
end

#tap_element(element) ⇒ void

Performs a tap on the element by tapping at the position of the element's rect.

The preferred method of tapping an element is to just call UIAutomation::Element#tap which calls the UIAElement tap() method directly on the element but this can sometimes fail on certain elements - this method is provided as a fallback.

Parameters:


38
39
40
# File 'lib/ui_automation/target.rb', line 38

def tap_element(element)
  perform(:tap, element.rect)
end