Module: Applitools::Selenium::Concerns::SeleniumEyes
- Included in:
- SeleniumEyes, VisualGridEyes
- Defined in:
- lib/applitools/selenium/concerns/selenium_eyes.rb
Constant Summary collapse
- USE_DEFAULT_MATCH_TIMEOUT =
-1
Instance Method Summary collapse
-
#check_frame(options = {}) ⇒ Applitools::MatchResult
Validates the contents of an iframe and matches it with the expected output.
-
#check_in_frame(options) ⇒ Object
Validates the contents of an iframe and matches it with the expected output.
-
#check_region(element, how = nil, what = nil, options = {}) ⇒ Object
Takes a snapshot of the application under test and matches a region of a specific element with the expected region output.
-
#check_region_in_frame(options = {}) ⇒ Applitools::MatchResult
Validates the contents of a region in an iframe and matches it with the expected output.
-
#check_window(*args) ⇒ Object
Takes a snapshot of the application under test and matches it with the expected output.
-
#test(options = {}) {|driver| ... } ⇒ Object
Use this method to perform seamless testing with selenium through eyes driver.
Instance Method Details
#check_frame(options = {}) ⇒ Applitools::MatchResult
Validates the contents of an iframe and matches it with the expected output.
95 96 97 98 99 100 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 95 def check_frame( = {}) = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge!() frame = [:frame] || [:frame_element] || [:name_or_id] target = Applitools::Selenium::Target.frame(frame).timeout([:timeout]).fully check([:tag], target) end |
#check_in_frame(options) ⇒ Object
Validates the contents of an iframe and matches it with the expected output.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 13 def check_in_frame() Applitools::ArgumentGuard.is_a? , 'options', Hash frames = .delete :target_frames Applitools::ArgumentGuard.is_a? frames, 'target_frames: []', Array return yield if block_given? && frames.empty? original_frame_chain = driver.frame_chain logger.info 'Switching to target frame according to frames path...' driver.switch_to.frames(frames_path: frames) frame_chain_to_reset = driver.frame_chain logger.info 'Done!' ensure_frame_visible yield if block_given? reset_frames_scroll_position(frame_chain_to_reset) logger.info 'Switching back into top level frame...' driver.switch_to.default_content return unless original_frame_chain logger.info 'Switching back into original frame...' driver.switch_to.frames frame_chain: original_frame_chain end |
#check_region(element, how = nil, what = nil, options = {}) ⇒ Object
Takes a snapshot of the application under test and matches a region of a specific element with the expected region output.
78 79 80 81 82 83 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 78 def check_region(*args) = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.(args) target = Applitools::Selenium::Target.new.region(*args).timeout([:match_timeout]) target.fully if [:stitch_content] check([:tag], target) end |
#check_region_in_frame(options = {}) ⇒ Applitools::MatchResult
Validates the contents of a region in an iframe and matches it with the expected output.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 113 def check_region_in_frame( = {}) = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil, stitch_content: false }.merge!() Applitools::ArgumentGuard.not_nil [:by], 'options[:by]' Applitools::ArgumentGuard.is_a? [:by], 'options[:by]', Array how_what = .delete(:by) frame = [:frame] || [:frame_element] || [:name_or_id] target = Applitools::Selenium::Target.new.timeout([:timeout]) target.frame(frame) if frame target.fully if [:stitch_content] target.region(*how_what) check([:tag], target) end |
#check_window(*args) ⇒ Object
Takes a snapshot of the application under test and matches it with the expected output.
def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 47 def check_window(*args) tag = args.select { |a| a.is_a?(String) || a.is_a?(Symbol) }.first match_timeout = args.select { |a| a.is_a?(Integer) }.first fully = args.select { |a| a.is_a?(TrueClass) || a.is_a?(FalseClass) }.first target = Applitools::Selenium::Target.window.tap do |t| t.timeout(match_timeout || USE_DEFAULT_MATCH_TIMEOUT) # fully = force_full_page_screenshot if fully.nil? t.fully(fully) if !fully.nil? end check(tag, target) end |
#test(options = {}) {|driver| ... } ⇒ Object
Use this method to perform seamless testing with selenium through eyes driver. It yields a block and passes to it an Applitools::Selenium::Driver instance, which wraps standard driver. Using Selenium methods inside the ‘test’ block will send the messages to Selenium after creating the Eyes triggers for them. Options are similar to open
140 141 142 143 144 145 146 |
# File 'lib/applitools/selenium/concerns/selenium_eyes.rb', line 140 def test( = {}, &_block) open() yield(driver) close ensure abort_if_not_closed end |