Class: Applitools::Appium::Eyes
- Inherits:
-
Selenium::Eyes
- Object
- Selenium::Eyes
- Applitools::Appium::Eyes
- Defined in:
- lib/applitools/appium/eyes.rb
Instance Method Summary collapse
- #capture_screenshot ⇒ Object
- #check(name, target) ⇒ Object
- #check_native(name, target) ⇒ Object
- #check_region(*args) ⇒ Object
- #check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT) ⇒ Object
- #dom_data ⇒ Object
- #get_app_output_with_screenshot(*args) ⇒ Object
-
#initialize(*args) ⇒ Eyes
constructor
A new instance of Eyes.
- #native_app? ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Eyes
Returns a new instance of Eyes.
9 10 11 12 |
# File 'lib/applitools/appium/eyes.rb', line 9 def initialize(*args) super self.dont_get_title = true end |
Instance Method Details
#capture_screenshot ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/applitools/appium/eyes.rb', line 51 def capture_screenshot logger.info 'Getting screenshot (capture_screenshot() has been invoked)' case eyes_element_to_check when Applitools::Region when Selenium::WebDriver::Element, Applitools::Selenium::Element element_screenshot end end |
#check(name, target) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/applitools/appium/eyes.rb', line 16 def check(name, target) logger.info "check(#{name}) is called" self.tag_for_debug = name Applitools::ArgumentGuard.one_of? target, 'target', [Applitools::Selenium::Target, Applitools::Appium::Target] return check_native(name, target) if native_app? super end |
#check_native(name, target) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/applitools/appium/eyes.rb', line 28 def check_native(name, target) logger.info "check_native(#{name}) is called" update_scaling_params target_to_check = target.finalize match_data = Applitools::MatchWindowData.new match_data.tag = name timeout = target_to_check.[:timeout] || USE_DEFAULT_MATCH_TIMEOUT eyes_element = target_to_check.region_to_check.call(driver) self.eyes_element_to_check = eyes_element region_provider = Applitools::Appium::RegionProvider.new(driver, eyes_element) match_data.read_target(target_to_check, driver) check_window_base( region_provider, timeout, match_data ) end |
#check_region(*args) ⇒ Object
92 93 94 95 96 |
# File 'lib/applitools/appium/eyes.rb', line 92 def check_region(*args) = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.(args) target = Applitools::Appium::Target.new.region(*args).timeout([:match_timeout]) check([:tag], target) end |
#check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/applitools/appium/eyes.rb', line 85 def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT) target = Applitools::Appium::Target.window.tap do |t| t.timeout(match_timeout) end check(tag, target) end |
#dom_data ⇒ Object
81 82 83 |
# File 'lib/applitools/appium/eyes.rb', line 81 def dom_data {} end |
#get_app_output_with_screenshot(*args) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/applitools/appium/eyes.rb', line 61 def get_app_output_with_screenshot(*args) super do |screenshot| if scale_provider scaled_image = scale_provider.scale_image(screenshot.image) self.screenshot = Applitools::Appium::Screenshot.new( Applitools::Screenshot.from_image( case scaled_image when ChunkyPNG::Image scaled_image when Applitools::Screenshot::Datastream scaled_image.image else raise Applitools::EyesError.new('Unknown image format after scale!') end ) ) end end end |
#native_app? ⇒ Boolean
46 47 48 49 |
# File 'lib/applitools/appium/eyes.rb', line 46 def native_app? return true if driver.current_context == 'NATIVE_APP' false end |