Class: TestCentricity::AppElements::AppSwitch
- Inherits:
-
AppUIElement
- Object
- AppUIElement
- TestCentricity::AppElements::AppSwitch
- Defined in:
- lib/testcentricity_apps/app_elements/switch.rb
Instance Attribute Summary
Attributes inherited from AppUIElement
#context, #locator, #mru_app_session, #mru_locator, #mru_object, #mru_parent, #name, #parent, #type
Instance Method Summary collapse
-
#initialize(name, parent, locator, context) ⇒ AppSwitch
constructor
A new instance of AppSwitch.
-
#off ⇒ Object
Set the state of a switch object to OFF.
-
#on ⇒ Object
Set the state of a switch object to ON.
-
#on? ⇒ Boolean
(also: #checked?, #selected?)
Is switch in ON state?.
-
#set_switch_state(state) ⇒ Object
Set the ON/OFF state of a switch object.
Methods inherited from AppUIElement
#clear, #click, #count, #disabled?, #double_tap, #drag_and_drop, #drag_by, #element, #enabled?, #exists?, #get_attribute, #get_caption, #get_locator, #get_name, #get_object_type, #get_value, #height, #hidden?, #hover, #id, #identifier, #long_press, #reset_mru_cache, #scroll_into_view, #send_keys, #set, #swipe_gesture, #tap, #visible?, #wait_until_enabled, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x_loc, #y_loc
Constructor Details
#initialize(name, parent, locator, context) ⇒ AppSwitch
Returns a new instance of AppSwitch.
4 5 6 7 |
# File 'lib/testcentricity_apps/app_elements/switch.rb', line 4 def initialize(name, parent, locator, context) super @type = :switch end |
Instance Method Details
#off ⇒ Object
Set the state of a switch object to OFF.
47 48 49 50 51 |
# File 'lib/testcentricity_apps/app_elements/switch.rb', line 47 def off obj = element object_not_found_exception(obj) obj.click if on? end |
#on ⇒ Object
Set the state of a switch object to ON.
36 37 38 39 40 |
# File 'lib/testcentricity_apps/app_elements/switch.rb', line 36 def on obj = element object_not_found_exception(obj) obj.click unless on? end |
#on? ⇒ Boolean Also known as: checked?, selected?
Is switch in ON state?
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/testcentricity_apps/app_elements/switch.rb', line 15 def on? obj = element object_not_found_exception(obj) if Environ.is_ios? state = obj.attribute(:value) state.to_bool else state = obj.attribute(:checked) state.boolean? ? state : state == 'true' end end |
#set_switch_state(state) ⇒ Object
Set the ON/OFF state of a switch object.
59 60 61 62 63 |
# File 'lib/testcentricity_apps/app_elements/switch.rb', line 59 def set_switch_state(state) obj = element object_not_found_exception(obj) state ? on : off end |