Class: Applitools::Selenium::EyesTargetLocator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Applitools::Selenium::EyesTargetLocator
- Extended by:
- Forwardable
- Defined in:
- lib/applitools/selenium/eyes_target_locator.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#on_will_switch ⇒ Object
readonly
Returns the value of attribute on_will_switch.
-
#scroll_position_provider ⇒ Object
readonly
Returns the value of attribute scroll_position_provider.
Instance Method Summary collapse
-
#active_element ⇒ Applitools::Selenium::Element
A wrapper for the native method
active_element
. -
#alert ⇒ Applitools::Selenium::EyesTargetLocator
A wrapper for a native method
alert
. -
#default_content ⇒ Applitools::Selenium::Driver
A wrapper for the native method
default_content
. -
#frame(*args) ⇒ Object
Set a certain iframe.
-
#frames(options = {}) ⇒ Object
Sets several frames.
-
#initialize(driver, original_target_locator, on_will_switch) ⇒ EyesTargetLocator
constructor
Initialize a class instance.
-
#parent_frame ⇒ Applitools::Selenium::Driver
Switches to parent frame.
-
#window(name_or_handle) ⇒ Applitools::Selenium::Driver
A wrapper for the native method
window
.
Constructor Details
#initialize(driver, original_target_locator, on_will_switch) ⇒ EyesTargetLocator
Initialize a class instance.
16 17 18 19 20 21 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 16 def initialize(driver, original_target_locator, on_will_switch) super(original_target_locator) @driver = driver @on_will_switch = on_will_switch @scroll_position_provider = Applitools::Selenium::ScrollPositionProvider.new(driver) end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
9 10 11 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 9 def driver @driver end |
#on_will_switch ⇒ Object (readonly)
Returns the value of attribute on_will_switch.
9 10 11 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 9 def on_will_switch @on_will_switch end |
#scroll_position_provider ⇒ Object (readonly)
Returns the value of attribute scroll_position_provider.
9 10 11 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 9 def scroll_position_provider @scroll_position_provider end |
Instance Method Details
#active_element ⇒ Applitools::Selenium::Element
A wrapper for the native method active_element
.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 112 def active_element logger.info 'EyesTargetLocator.active_element()' logger.info 'Switching to element...' element = __getobj__.active_element unless element.is_a? Selenium::WebDriver::Element raise Applitools::EyesError.new( 'Not an Selenium::WebDriver::Element!' ) end result = Applitools::Selenium::Element.new driver, element logger.info 'Done!' result end |
#alert ⇒ Applitools::Selenium::EyesTargetLocator
A wrapper for a native method alert
.
132 133 134 135 136 137 138 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 132 def alert logger.info 'EyesTargetLocator.alert()' logger.info 'Switching to alert...' result = __getobj__.alert logger.info 'Done!' result end |
#default_content ⇒ Applitools::Selenium::Driver
A wrapper for the native method default_content
.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 84 def default_content logger.info 'EyesTargetLocator.default_content()' unless driver.frame_chain.empty? logger.info 'Making preparations...' on_will_switch.will_switch_to_frame :default_content, nil logger.info 'Done! Switching to default content...' __getobj__.default_content logger.info 'Done!' end driver end |
#frame(*args) ⇒ Object
Set a certain iframe.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 29 def frame(*args) case value = args[0] when Hash = value raise Applitools::EyesIllegalArgument.new 'You must pass :index or :name_or_id or :frame_element option' unless [:index] || [:name_or_id] || [:frame_element] if (needed_keys = (.keys & [:index, :name_or_id, :frame_element])).length == 1 send "frame_by_#{needed_keys.first}", [needed_keys.first] else raise Applitools::EyesIllegalArgument.new 'You\'ve passed some extra keys!' / 'Only :index, :name_or_id or :frame_elenent are allowed.' end when Applitools::Selenium::Element frame_by_frame_element(value) when String frame_by_name_or_id(value) else raise Applitools::EyesError, 'Unknown frame selector to switch!' end end |
#frames(options = {}) ⇒ Object
Sets several frames.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 69 def frames( = {}) raise Applitools::EyesIllegalArgument.new 'You must pass :frame_chain or :frames_path' if [:frame_chain].nil? & [:frames_path].nil? if (needed_keys = (.keys & [:frame_chain, :frames_path])).length == 1 send "frames_by_#{needed_keys.first}", [needed_keys.first] else raise Applitools::EyesIllegalArgument.new 'You\'ve passed some extra keys!' / 'Only :frame_index or :frames_path are allowed.' end end |
#parent_frame ⇒ Applitools::Selenium::Driver
Switches to parent frame.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 53 def parent_frame logger.info 'EyesTargetLocator.parent_frame()' unless driver.frame_chain.empty? on_will_switch.will_switch_to_frame :parent_frame, nil logger.info 'Done! Switching to parent_frame...' __getobj__.parent_frame end logger.info 'Done!' driver end |
#window(name_or_handle) ⇒ Applitools::Selenium::Driver
A wrapper for the native method window
.
99 100 101 102 103 104 105 106 107 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 99 def window(name_or_handle) logger.info 'EyesTargetLocator.window()' logger.info 'Making preparaions...' # on_will_switch.will_switch_to_window name_or_handle logger.info 'Done! Switching to window..' __getobj__.window name_or_handle logger.info 'Done!' driver end |