eyes_appium 3.14.6 → 3.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4343ca9e6659a07c3983445b01ba7fb035cca25ccc468c21e248b35c949457f
4
- data.tar.gz: c3956f3a199756c5567e9e1adcae4bfe5de6aeed29d11b9fbc4e0ea810ce6b90
3
+ metadata.gz: 8ae5c6b84c2efcceca2be48b2753654fc11daf5c10106b67a98562d40a4a7212
4
+ data.tar.gz: 897a8cd6f6306f87e743e692a1e5de9aae4494ff56f79344eebe99268ee71e71
5
5
  SHA512:
6
- metadata.gz: 4d7ecf5d2b57bc936340deeb3b6481cf29d32749b99fdce493f6e42afdcb758f682f2615f37534687b7ccbdfb2548cfecab5a3adbcac0bff5ac74ecc4623a470
7
- data.tar.gz: a14ea0ccb19d651dadb5ff056a86c6cc7814f48a33d5c6d9ba71323b527c047e13ec86937efcf3a006d91dc9694db39660fcede8807699fe85443aacaa862395
6
+ metadata.gz: bb45150ea47662d44b54fe290e3a093170c75c698b864236a7d5089dc5201e44ae420045408ec95b8d29cff9e76fa5c07bcf2c50aecb7083d92fac035f797acf
7
+ data.tar.gz: 41d71ee8e1b1c4e7253bd5133146fd5e989c36b596d4a8398ea13a9f46e836e88678d2e87af9e506c70898a015456f083f57f43a05468c7220e58ce1586bb994
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Applitools::Appium
4
+ class Driver < Applitools::Selenium::Driver
5
+ attr_accessor :appium_driver
6
+ def initialize(eyes, options)
7
+ self.appium_driver = options.delete(:appium_driver)
8
+ super(eyes, options)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: false
2
+
3
+ class Applitools::Appium::Eyes < Applitools::Selenium::Eyes
4
+ def perform_driver_settings_for_appium_driver
5
+ self.region_visibility_strategy = Applitools::Selenium::NopRegionVisibilityStrategy.new
6
+ self.force_driver_resolution_as_viewport_size = true
7
+ end
8
+
9
+ def initialize(*args)
10
+ super
11
+ self.dont_get_title = true
12
+ end
13
+
14
+ private :perform_driver_settings_for_appium_driver
15
+
16
+ def check(name, target)
17
+ logger.info "check(#{name}) is called"
18
+ self.tag_for_debug = name
19
+ Applitools::ArgumentGuard.one_of? target, 'target', [Applitools::Selenium::Target, Applitools::Appium::Target]
20
+
21
+ return check_native(name, target) if native_app?
22
+ super
23
+ end
24
+
25
+ attr_accessor :eyes_element_to_check, :region_provider
26
+ private :eyes_element_to_check, :eyes_element_to_check=, :region_provider, :region_provider=
27
+
28
+ def check_native(name, target)
29
+ logger.info "check_native(#{name}) is called"
30
+ update_scaling_params
31
+ target_to_check = target.finalize
32
+ match_data = Applitools::MatchWindowData.new
33
+ match_data.tag = name
34
+ timeout = target_to_check.options[:timeout] || USE_DEFAULT_MATCH_TIMEOUT
35
+
36
+ eyes_element = target_to_check.region_to_check.call(driver)
37
+ self.eyes_element_to_check = eyes_element
38
+ region_provider = Applitools::Appium::RegionProvider.new(driver, eyes_element)
39
+ match_data.read_target(target_to_check, driver)
40
+
41
+ check_window_base(
42
+ region_provider, timeout, match_data
43
+ )
44
+ end
45
+
46
+ def native_app?
47
+ return true if driver.current_context == 'NATIVE_APP'
48
+ false
49
+ end
50
+
51
+ def capture_screenshot
52
+ logger.info 'Getting screenshot (capture_screenshot() has been invoked)'
53
+ case eyes_element_to_check
54
+ when Applitools::Region
55
+ viewport_screenshot
56
+ when Selenium::WebDriver::Element, Applitools::Selenium::Element
57
+ element_screenshot
58
+ end
59
+ end
60
+
61
+ def get_app_output_with_screenshot(*args)
62
+ super do |screenshot|
63
+ if scale_provider
64
+ scaled_image = scale_provider.scale_image(screenshot.image)
65
+ self.screenshot = Applitools::Appium::Screenshot.new(
66
+ Applitools::Screenshot.from_image(
67
+ case scaled_image
68
+ when ChunkyPNG::Image
69
+ scaled_image
70
+ when Applitools::Screenshot::Datastream
71
+ scaled_image.image
72
+ else
73
+ raise Applitools::EyesError.new('Unknown image format after scale!')
74
+ end
75
+ )
76
+ )
77
+ end
78
+ end
79
+ end
80
+
81
+ def dom_data
82
+ {}
83
+ end
84
+
85
+ def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
86
+ target = Applitools::Appium::Target.window.tap do |t|
87
+ t.timeout(match_timeout)
88
+ end
89
+ check(tag, target)
90
+ end
91
+
92
+ def check_region(*args)
93
+ options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.extract_options!(args)
94
+ target = Applitools::Appium::Target.new.region(*args).timeout(options[:match_timeout])
95
+ check(options[:tag], target)
96
+ end
97
+
98
+ private
99
+
100
+ def viewport_screenshot
101
+ logger.info 'Viewport screenshot requested...'
102
+ self.screenshot = Applitools::Appium::Screenshot.new(
103
+ Applitools::Screenshot.from_datastream(driver.screenshot_as(:png))
104
+ )
105
+ end
106
+
107
+ def element_screenshot
108
+ logger.info 'Element screenshot requested...'
109
+ self.screenshot = Applitools::Appium::Screenshot.new(
110
+ Applitools::Screenshot.from_datastream(
111
+ driver.element_screenshot_as(eyes_element_to_check, :png)
112
+ )
113
+ )
114
+ end
115
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: false
2
+
3
+ module Applitools::Appium
4
+ module Init19
5
+ extend self
6
+
7
+ def init
8
+ Applitools::Utils::EyesSeleniumUtils.module_eval do
9
+ alias_method :super_mobile_device?, :mobile_device?
10
+ alias_method :super_android?, :android?
11
+ alias_method :super_ios?, :ios?
12
+ alias_method :super_platform_version, :platform_version
13
+ alias_method :super_current_scroll_position, :current_scroll_position
14
+ include Applitools::Appium::Utils
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: false
2
+
3
+ module Applitools::Appium
4
+ module Init20
5
+ extend self
6
+ def init
7
+ Applitools::Utils::EyesSeleniumUtils.module_eval do
8
+ prepend Applitools::Appium::Utils
9
+ extend self
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Applitools
4
+ module Appium
5
+ class RegionProvider
6
+ attr_accessor :driver, :eye_region, :coordinate_type
7
+
8
+ def initialize(driver, eye_region)
9
+ self.driver = driver
10
+ self.eye_region = eye_region
11
+ end
12
+
13
+ def region
14
+ return Applitools::Region::EMPTY if
15
+ [::Selenium::WebDriver::Element, Applitools::Selenium::Element].include? eye_region.class
16
+ region = driver.session_capabilities['viewportRect']
17
+ Applitools::Region.new(
18
+ region['left'],
19
+ region['top'],
20
+ region['width'],
21
+ region['height']
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Applitools
4
+ module Appium
5
+ class Screenshot < Applitools::EyesScreenshot
6
+ def sub_screenshot(region, _coordinate_type, _throw_if_clipped = false, _force_nil_if_clipped = false)
7
+ self.class.new(
8
+ Applitools::Screenshot.from_image(
9
+ image.crop(region.x, region.y, region.width, region.height)
10
+ )
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Applitools
4
+ module Appium
5
+ class Target
6
+ include Applitools::FluentInterface
7
+
8
+ attr_accessor :region_to_check, :options
9
+
10
+ class << self
11
+ def window
12
+ new
13
+ end
14
+
15
+ def region(*args)
16
+ new.region(*args)
17
+ end
18
+ end
19
+
20
+ def initialize
21
+ self.region_to_check = proc { Applitools::Region::EMPTY }
22
+ self.options = {}
23
+ end
24
+
25
+ def region(*args)
26
+ self.region_to_check = case args.first
27
+ when ::Selenium::WebDriver::Element
28
+ proc { args.first }
29
+ else
30
+ proc do |driver|
31
+ driver.find_element(*args)
32
+ end
33
+ end
34
+ self
35
+ end
36
+
37
+ def finalize
38
+ self
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: false
2
+
3
+ module Applitools::Appium
4
+ module Utils
5
+ # true if test is running on mobile device
6
+ def mobile_device?(driver)
7
+ defined?(Appium::Driver) && driver.respond_to?(:appium_driver) && driver.appium_driver
8
+ end
9
+
10
+ # true if test is running on Android device
11
+ def android?(driver)
12
+ driver.respond_to?(:device_is_android?) && driver.device_is_android?
13
+ end
14
+
15
+ # true if test is running on iOS device
16
+ def ios?(driver)
17
+ driver.respond_to?(:device_is_ios?) && driver.device_is_ios?
18
+ end
19
+
20
+ # @param [Applitools::Selenium::Driver] driver
21
+ def platform_version(driver)
22
+ driver.respond_to?(:caps) && driver.caps[:platformVersion]
23
+ end
24
+
25
+ # @param [Applitools::Selenium::Driver] executor
26
+ def device_pixel_ratio(executor)
27
+ if executor.respond_to? :session_capabilities
28
+ session_info = executor.session_capabilities
29
+ return session_info['pixelRatio'].to_f if session_info['pixelRatio']
30
+ end
31
+ Applitools::Selenium::Eyes::UNKNOWN_DEVICE_PIXEL_RATIO
32
+ end
33
+
34
+ def current_scroll_position(driver)
35
+ super
36
+ rescue
37
+ Applitools::Location::TOP_LEFT
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '3.14.6'.freeze
4
+ VERSION = '3.14.7'.freeze
5
5
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: false
2
+
3
+ require 'eyes_selenium'
4
+ require 'appium_lib'
5
+
6
+ CURRENT_RUBY_VERSION = Gem::Version.new RUBY_VERSION
7
+
8
+ RUBY_1_9_3 = Gem::Version.new '1.9.3'
9
+ RUBY_2_0_0 = Gem::Version.new '2.0.0'
10
+ RUBY_2_1_6 = Gem::Version.new '2.1.6'
11
+ RUBY_2_2_2 = Gem::Version.new '2.2.2'
12
+ RUBY_2_4_0 = Gem::Version.new '2.4.0'
13
+
14
+ RUBY_KEY = [RUBY_1_9_3, RUBY_2_0_0, RUBY_2_1_6, RUBY_2_2_2, RUBY_2_4_0].select { |v| v <= CURRENT_RUBY_VERSION }.last
15
+
16
+ Applitools.require_dir('appium')
17
+
18
+ if RUBY_KEY >= RUBY_2_0_0
19
+ Applitools::Appium::Init20.init
20
+ else
21
+ Applitools::Appium::Init19.init
22
+ end
23
+
24
+ if defined? Appium::Driver
25
+ Appium::Driver.class_eval do
26
+ def driver_for_eyes(eyes)
27
+ Applitools::Appium::Driver.new(eyes, driver: driver || start_driver, is_mobile_device: true, appium_driver: self)
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_appium
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.6
4
+ version: 3.14.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.14.6
19
+ version: 3.14.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.14.6
26
+ version: 3.14.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appium_lib
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -45,10 +45,16 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - lib/applitools/capybara/capybara_settings.rb
49
- - lib/applitools/capybara/driver.rb
48
+ - lib/applitools/appium/driver.rb
49
+ - lib/applitools/appium/eyes.rb
50
+ - lib/applitools/appium/initialize_1.9.rb
51
+ - lib/applitools/appium/initialize_2.0.rb
52
+ - lib/applitools/appium/region_provider.rb
53
+ - lib/applitools/appium/screenshot.rb
54
+ - lib/applitools/appium/target.rb
55
+ - lib/applitools/appium/utils.rb
50
56
  - lib/applitools/version.rb
51
- - lib/eyes_capybara.rb
57
+ - lib/eyes_appium.rb
52
58
  homepage: https://www.applitools.com
53
59
  licenses:
54
60
  - Apache-2.0
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Selenium
5
- module Capybara
6
- module CapybaraSettings
7
- # Registers Capybara driver which will be used by eyes and sets it as default Capybara driver.
8
- # The name of the driver is :eyes, and the driver is a descendant of class Capybara::Selenium::Driver.
9
- # Options are eventually passed to drivers constructor
10
- # @param [Hash] options
11
- # @example
12
- # Applitools.register_capybara_driver :browser => :chrome
13
- # @example
14
- # Applitools.register_capybara_driver :browser => :remote, :url => 'remote_url', :desired_capabilities => {}
15
- def register_capybara_driver(options = {})
16
- ::Capybara.register_driver :eyes do |app|
17
- Applitools::Selenium::Capybara::Driver.new app, options
18
- end
19
- ::Capybara.default_driver = :eyes
20
- ::Capybara.javascript_driver = :eyes
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if defined? Capybara::Selenium::Driver
4
- module Applitools::Selenium::Capybara
5
- # @!visibility private
6
- class Driver < Capybara::Selenium::Driver
7
- def driver_for_eyes(eyes)
8
- browser eyes: eyes
9
- end
10
-
11
- def browser(options = {})
12
- eyes = options.delete(:eyes)
13
- @native_browser ||= super()
14
- unless eyes.nil?
15
- is_mobile_device = @browser.capabilities['platformName'] ? true : false
16
- @browser = Applitools::Selenium::Driver.new eyes,
17
- options.merge(driver: @browser, is_mobile_device: is_mobile_device)
18
- end
19
- @browser
20
- end
21
-
22
- def use_native_browser
23
- @browser = @native_browser
24
- end
25
- end
26
- end
27
- end
28
-
29
- if defined? ::Capybara::Session
30
- ::Capybara::Session.class_eval do
31
- def driver_for_eyes(eyes)
32
- driver.driver_for_eyes eyes
33
- end
34
-
35
- def use_native_browser
36
- driver.use_native_browser if driver.respond_to? :use_native_browser
37
- end
38
- end
39
- end
data/lib/eyes_capybara.rb DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eyes_selenium'
4
- require 'capybara'
5
-
6
- module Applitools
7
- module Selenium
8
- module Capybara
9
- extend Applitools::RequireUtils
10
- def self.load_dir
11
- File.dirname(File.expand_path(__FILE__))
12
- end
13
- end
14
- end
15
- end
16
-
17
- Applitools::Selenium::Capybara.require_dir 'capybara'
18
-
19
- module Applitools
20
- extend Applitools::Selenium::Capybara::CapybaraSettings
21
- register_capybara_driver
22
- end