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(options = {}) ⇒ 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.
14 15 16 17 18 19 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 14 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.
7 8 9 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 7 def driver @driver end |
#on_will_switch ⇒ Object (readonly)
Returns the value of attribute on_will_switch.
7 8 9 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 7 def on_will_switch @on_will_switch end |
#scroll_position_provider ⇒ Object (readonly)
Returns the value of attribute scroll_position_provider.
7 8 9 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 7 def scroll_position_provider @scroll_position_provider end |
Instance Method Details
#active_element ⇒ Applitools::Selenium::Element
A wrapper for the native method active_element
.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 100 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
.
120 121 122 123 124 125 126 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 120 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
.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 72 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(options = {}) ⇒ Object
Set a certain iframe.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 27 def frame( = {}) 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 end |
#frames(options = {}) ⇒ Object
Sets several frames.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 57 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.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 41 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
.
87 88 89 90 91 92 93 94 95 |
# File 'lib/applitools/selenium/eyes_target_locator.rb', line 87 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 |