eyes_selenium 3.6.8 → 3.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0ba303b56fbfe37317a95906df6aa448d0fc03e
4
- data.tar.gz: 6a6c2742e1636c2dc374b41641e9d3c4444c737a
3
+ metadata.gz: ec128f5f784cf650ef0813cbe6f3f8723f928ec0
4
+ data.tar.gz: 96fef4717ef49d6ba7a8d73ee4b3b7e15c82fae0
5
5
  SHA512:
6
- metadata.gz: 1694ee6dd79bad5c22eb191fb8ac20b3131bafcbe7f39fb97ce67698879005e0bdca906ffe2ef2197c61dc11c7f3e7e17f8380319dd2c11323459e9b784f4a58
7
- data.tar.gz: adbe9e6af50014fdaa19d53d40812cf5e6eea1da6e799c855e3d66f9ebacec8d79b9bc517af5f58a07aaa30fed15c8c2bac96b3251e3d3cf83281c8a235e2eb6
6
+ metadata.gz: dbd2ea8b825228f633ad96e340bfa4dc8759634dfe617c6c665a1c957157110277f56554efe18d70ee70c77420d39b10e0f8c8f9c403d6655483a5e61ed5325b
7
+ data.tar.gz: 5d48ebf42e9e285390f9d6f54da5654891d53e9a9d39b78b4743f4617059fa9c22d72667c0a6dbd1caf9006d8ddc4bf9181bc5371f0737c786f4a10d2dd29f51
@@ -7,6 +7,9 @@ module Applitools::Selenium
7
7
 
8
8
  attr_accessor :element, :location, :size
9
9
 
10
+ # Initialize class instance.
11
+ #
12
+ # @param [Applitools::Selenium::Element] element The target element.
10
13
  def initialize(element)
11
14
  raise Applitools::EyesIllegalArgument.new 'Passed element is not Applitools::Selenium::Element instance!' unless
12
15
  element.is_a? Applitools::Selenium::Element
@@ -59,6 +59,10 @@ module Applitools::Selenium
59
59
  MAX_SCROLLBAR_SIZE = 50
60
60
  OVERFLOW_HIDDEN = 'hidden'.freeze
61
61
 
62
+ # Initialize class instance.
63
+ #
64
+ # @param [Applitools::Selenium::Driver] driver The wrapped Selenium driver.
65
+ # @param [Applitools::Selenium::Eyes] eyes The eyes instance.
62
66
  def initialize(driver, eyes)
63
67
  @driver = driver
64
68
  @eyes = eyes
@@ -80,6 +84,10 @@ module Applitools::Selenium
80
84
  end
81
85
  end
82
86
 
87
+ # Gets the normalization factor.
88
+ #
89
+ # @param [ChunkyPNG::Canvas] image The image to normalize.
90
+ # @return [Integer] The image normalization factor.
83
91
  def image_normalization_factor(image)
84
92
  # If the user manually set the scale ratio, we use that.
85
93
  return @eyes.scale_ratio unless @eyes.scale_ratio.nil?
@@ -92,6 +100,9 @@ module Applitools::Selenium
92
100
  1.to_f / device_pixel_ratio
93
101
  end
94
102
 
103
+ # The dimensions of the entire page.
104
+ #
105
+ # @return [Applitools::Base::Dimension] The dimensions of the entire page.
95
106
  def entire_page_size
96
107
  max_document_element_height = [page_metrics[:client_height], page_metrics[:scroll_height]].max
97
108
  max_body_height = [page_metrics[:body_client_height], page_metrics[:body_scroll_height]].max
@@ -102,6 +113,9 @@ module Applitools::Selenium
102
113
  Applitools::Base::Dimension.new(total_width, total_height)
103
114
  end
104
115
 
116
+ # Returns the current scroll position.
117
+ #
118
+ # @return [Applitools::Base::Point] The coordinates of the scroll position.
105
119
  def current_scroll_position
106
120
  position = Applitools::Utils.underscore_hash_keys(execute_script(JS_GET_CURRENT_SCROLL_POSITION))
107
121
  Applitools::Base::Point.new(position[:left], position[:top])
@@ -135,6 +149,9 @@ module Applitools::Selenium
135
149
  set_transform("translate(-#{point.left}px, -#{point.top}px)")
136
150
  end
137
151
 
152
+ # Takes a full page screenshot.
153
+ #
154
+ # @return [ChunkyPNG::Canvas] image The result of the screenshot.
138
155
  def fullpage_screenshot
139
156
  # Scroll to the top/left corner of the screen.
140
157
  original_scroll_position = current_scroll_position
@@ -7,6 +7,12 @@ module Applitools::Selenium
7
7
 
8
8
  attr_reader :top_level_context_entire_size, :viewport_size, :device_pixel_ratio, :scale_ratio
9
9
 
10
+ # Initialize a class instance.
11
+ #
12
+ # @param [Applitools::RectangleSize] top_level_context_entire_size The entire
13
+ # size of the context.
14
+ # @param [Hash] viewport_size The required browser's viewport size.
15
+ # @param [Fixnum] device_pixel_ratio The device's pixel ratio.
10
16
  def initialize(top_level_context_entire_size, viewport_size, device_pixel_ratio)
11
17
  @top_level_context_entire_size = top_level_context_entire_size
12
18
  @viewport_size = viewport_size
@@ -14,6 +20,9 @@ module Applitools::Selenium
14
20
  @scale_ratio = UNKNOWN_SCALE_RATIO
15
21
  end
16
22
 
23
+ # Scales the image.
24
+ #
25
+ # @param [Screenshot::Datastream] image The image to scale.
17
26
  def scale_image(image)
18
27
  if @scale_ratio == UNKNOWN_SCALE_RATIO
19
28
  @scale_ratio = if ((image.width >= viewport_size.width - ALLOWED_VS_DEVIATION) &&
@@ -28,6 +37,9 @@ module Applitools::Selenium
28
37
  Applitools::Utils::ImageUtils.scale!(image, scale_ratio)
29
38
  end
30
39
 
40
+ # Gets the scale ratio.
41
+ #
42
+ # @return [Fixnum] The scale ratio.
31
43
  def scale_ratio
32
44
  raise Applitools::EyesError.new 'Scale ratio is not defined yet!' if @scale_ratio == UNKNOWN_SCALE_RATIO
33
45
  @scale_ratio
@@ -6,6 +6,13 @@ module Applitools::Selenium
6
6
 
7
7
  attr_accessor :last_state_position
8
8
 
9
+ # Initialize a class instance.
10
+ #
11
+ # @param [Applitools::Selenium::Driver] executor The driver instance.
12
+ # @param [Boolean] disable_horizontal Whether to disable horizontal movement or not.
13
+ # @param [Boolean] disable_vertical Whether to disable vertical movement or not.
14
+ # @param [Integer] max_width The max width.
15
+ # @param [Integer] max_height The max height.
9
16
  def initialize(executor, disable_horizontal = false, disable_vertical = false, max_width: nil, max_height: nil)
10
17
  self.executor = executor
11
18
  self.disable_horizontal = disable_horizontal
@@ -22,6 +29,9 @@ module Applitools::Selenium
22
29
  Applitools::Utils::EyesSeleniumUtils.current_transforms(executor)
23
30
  end
24
31
 
32
+ # Restore last state position.
33
+ #
34
+ # @param [Applitools::Location] value The location.
25
35
  def restore_state(value)
26
36
  transforms = value.values.select { |el| !el.empty? }
27
37
  Applitools::Utils::EyesSeleniumUtils.set_transforms(executor, value)
@@ -48,6 +58,9 @@ module Applitools::Selenium
48
58
 
49
59
  alias scroll_to position=
50
60
 
61
+ # Gets the entire size of the frame.
62
+ #
63
+ # @return [Applitools::RectangleSize] The entire size of the frame.
51
64
  def entire_size
52
65
  viewport_size = Applitools::Utils::EyesSeleniumUtils.extract_viewport_size(executor)
53
66
  result = Applitools::Utils::EyesSeleniumUtils.current_frame_content_entire_size(executor)
@@ -35,7 +35,13 @@ module Applitools::Selenium
35
35
  def_delegators :@browser, :user_agent
36
36
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
37
37
 
38
+ # Initializes a class instance.
39
+ #
38
40
  # If driver is not provided, Applitools::Selenium::Driver will raise an EyesError exception.
41
+ # @param eyes [Applitools::Selenium::Eyes] The eyes instance.
42
+ # @param options [Hash] The options.
43
+ # @option options [Selenium::WebDriver::Driver] :driver The Selenium webdriver instance.
44
+ # @option options [Boolean] :is_mobile_device Whether is a mobile device or not.
39
45
  def initialize(eyes, options)
40
46
  super(options[:driver])
41
47
  @is_mobile_device = options.fetch(:is_mobile_device, false)
@@ -46,17 +52,22 @@ module Applitools::Selenium
46
52
  Applitools::EyesLogger.warn '"screenshot_as" method not found!' unless driver.respond_to? :screenshot_as
47
53
  end
48
54
 
49
- # Executes javascript in browser context
55
+ # Executes javascript in browser context.
56
+ #
50
57
  # @raise [Applitools::EyesDriverOperationException]
51
58
  def execute_script(*args)
52
59
  raises_error { __getobj__.execute_script(*args) }
53
60
  end
54
61
 
62
+ # Returns the platform name.
63
+ #
55
64
  # @return [String] The platform name or +nil+ if it is undefined.
56
65
  def platform_name
57
66
  capabilities['platformName']
58
67
  end
59
68
 
69
+ # Returns the platform version.
70
+ #
60
71
  # @return [String] The platform version or +nil+ if it is undefined.
61
72
  def platform_version
62
73
  version = capabilities['platformVersion']
@@ -88,6 +99,7 @@ module Applitools::Selenium
88
99
  end
89
100
 
90
101
  # Returns native driver
102
+ #
91
103
  # @return Selenium::WebDriver
92
104
  def remote_web_driver
93
105
  driver
@@ -95,7 +107,8 @@ module Applitools::Selenium
95
107
 
96
108
  alias set_overflow overflow=
97
109
 
98
- # Takes a screenshot
110
+ # Takes a screenshot.
111
+ #
99
112
  # @param [:Symbol] format A format to store screenshot (one of +:base64+ or +:png+)
100
113
  # @return [String] A byte string, representing the screenshot
101
114
  def screenshot_as(format)
@@ -123,6 +136,11 @@ module Applitools::Selenium
123
136
  # @return [Applitools::Selenium::Element]
124
137
  # @!parse def find_element(how, what); end
125
138
 
139
+ # Finds an element in a window.
140
+ #
141
+ # @param [Array] *args The arguments for finding the element (at most contains 2 params).
142
+ # @option args [Symbol] :by By what means to search for the element (e.g. :css, :id).
143
+ # @option args [String] Name of element.
126
144
  def find_element(*args)
127
145
  how, what = extract_args(args)
128
146
 
@@ -147,6 +165,11 @@ module Applitools::Selenium
147
165
  # @return [ [Applitools::Selenium::Element] ]
148
166
  # @!parse def find_elements(how, what); end
149
167
 
168
+ # Finds elements in a window.
169
+ #
170
+ # @param [Array] *args The arguments for finding the element (at most contains 2 params).
171
+ # @option args [Symbol] :by By what means to search for the element (e.g. :css, :id).
172
+ # @option args [String] Name of elements.
150
173
  def find_elements(*args)
151
174
  how, what = extract_args(args)
152
175
 
@@ -166,7 +189,9 @@ module Applitools::Selenium
166
189
  end
167
190
 
168
191
  # Returns a copy of current frame chain. Frame chain stores information about all parent frames,
169
- # including scroll offset an frame coordinates
192
+ # including scroll offset an frame coordinates.
193
+ #
194
+ # @return [Applitools::Selenium::FrameChain] The frame chain.
170
195
  def frame_chain
171
196
  Applitools::Selenium::FrameChain.new other: @frame_chain
172
197
  end
@@ -177,10 +202,11 @@ module Applitools::Selenium
177
202
  @frame_chain
178
203
  end
179
204
 
180
- # Gets +default_content_viewport_size+
205
+ # Gets +default_content_viewport_size+.
206
+ #
181
207
  # @param [Boolean] force_query if set to true, forces querying of viewport size from the browser,
182
- # otherwise returns cached value
183
- # @return [Applitools::RectangleSize]
208
+ # otherwise returns cached value.
209
+ # @return [Applitools::RectangleSize] The default content viewport size.
184
210
  def default_content_viewport_size(force_query = false)
185
211
  logger.info('default_content_viewport_size()')
186
212
  if cached_default_content_viewport_size && !force_query
@@ -30,6 +30,10 @@ module Applitools::Selenium
30
30
 
31
31
  # def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
32
32
 
33
+ # Initialize class instance.
34
+ #
35
+ # @param [Applitools::Selenium::Driver] driver The wrapped Selenium driver instance.
36
+ # @param [Applitools::Selenium::Element] element The wrapped Selenium element instance.
33
37
  def initialize(driver, element)
34
38
  super(element)
35
39
 
@@ -62,6 +66,10 @@ module Applitools::Selenium
62
66
 
63
67
  alias eql? ==
64
68
 
69
+ # Types content into text box.
70
+ #
71
+ # @param [Array] *args The arguments.
72
+ # @option *args [String] The content to type.
65
73
  def send_keys(*args)
66
74
  Selenium::WebDriver::Keys.encode(args).each do |key|
67
75
  @driver.add_text_trigger(self, key.to_s)
@@ -70,6 +78,9 @@ module Applitools::Selenium
70
78
  end
71
79
  alias send_key send_keys
72
80
 
81
+ # Gets the bounds of the element.
82
+ #
83
+ # @return [Applitools::Base::Region] An instance of the region.
73
84
  def bounds
74
85
  point = location
75
86
  left = point.x
@@ -4,6 +4,10 @@ module Applitools::Selenium
4
4
  extend Forwardable
5
5
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
6
6
 
7
+ # Initialize a class instance.
8
+ #
9
+ # @param [Applitools::Selenium::Driver] executor The wrapped Selenium driver instance.
10
+ # @param [Applitools::Selenium::Element] passed_element The wrapped Selenium element instance.
7
11
  def initialize(executor, passed_element)
8
12
  Applitools::ArgumentGuard.not_nil 'executor', executor
9
13
  Applitools::ArgumentGuard.not_nil 'passed_element', passed_element
@@ -13,6 +17,9 @@ module Applitools::Selenium
13
17
  element.is_a? Applitools::Selenium::Element
14
18
  end
15
19
 
20
+ # Gets the current position.
21
+ #
22
+ # @return [Applitools::Location] The location.
16
23
  def current_position
17
24
  logger.info 'current_position() has called.'
18
25
  result = Applitools::Location.for element.scroll_left, element.scroll_top
@@ -20,6 +27,9 @@ module Applitools::Selenium
20
27
  result
21
28
  end
22
29
 
30
+ # Gets the enitire size of the element.
31
+ #
32
+ # @return [Applitools::RectangleSize] The size of the element.
23
33
  def entire_size
24
34
  logger.info 'entire_size()'
25
35
  result = Applitools::RectangleSize.new(element.scroll_width, element.scroll_height)
@@ -36,6 +36,10 @@ module Applitools::Selenium
36
36
  end
37
37
  end
38
38
 
39
+ # Set the viewport size.
40
+ #
41
+ # @param [Applitools::Selenium::Driver] driver The driver instance.
42
+ # @param [Hash] viewport_size The required browser's viewport size.
39
43
  def set_viewport_size(driver, viewport_size)
40
44
  Applitools::ArgumentGuard.not_nil(driver, 'Driver')
41
45
  Applitools::ArgumentGuard.not_nil(viewport_size, 'viewport_size')
@@ -84,7 +88,8 @@ module Applitools::Selenium
84
88
 
85
89
  # Creates a new (possibly disabled) Eyes instance that interacts with the
86
90
  # Eyes Server at the specified url.
87
- # @param server_url The Eyes Server URL
91
+ #
92
+ # @param server_url The Eyes Server URL.
88
93
  def initialize(server_url = nil)
89
94
  super
90
95
  self.base_agent_id = "eyes.selenium.ruby/#{Applitools::VERSION}".freeze
@@ -104,6 +109,7 @@ module Applitools::Selenium
104
109
  end
105
110
 
106
111
  # Starts a test
112
+ #
107
113
  # @param options [Hash] options
108
114
  # @option options :driver The driver that controls the browser hosting the application
109
115
  # under the test. (*Required* option)
@@ -157,6 +163,12 @@ module Applitools::Selenium
157
163
  @driver
158
164
  end
159
165
 
166
+ # Sets the stitch mode.
167
+ #
168
+ # @param [Hash] value The desired type of stitching (:SCROLL is default).
169
+ # @option value [Symbol] :css use Css to perform stitching.
170
+ # @option value [Symbol] :scroll Scroll to perform stitching.
171
+ # @return [Symbol] The type of stitching.
160
172
  def stitch_mode=(value)
161
173
  @stitch_mode = value.to_s.upcase == STICH_MODE[:css].to_s ? STICH_MODE[:css] : STICH_MODE[:scroll]
162
174
  unless driver.nil?
@@ -174,6 +186,7 @@ module Applitools::Selenium
174
186
  end
175
187
 
176
188
  # Takes a snapshot of the application under test and matches it with the expected output.
189
+ #
177
190
  # @param [String] tag An optional tag to be assosiated with the snapshot.
178
191
  # @param [Fixnum] match_timeout The amount of time to retry matching (seconds)
179
192
  def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
@@ -227,6 +240,11 @@ module Applitools::Selenium
227
240
  Applitools::Utils::EyesSeleniumUtils.extract_viewport_size(driver)
228
241
  end
229
242
 
243
+ # Takes a snapshot and matches it with the expected output.
244
+ #
245
+ # @param [String] name The name of the tag.
246
+ # @param [Applitools::Selenium::Target] target which area of the window to check.
247
+ # @return [Applitools::MatchResult] The match results.
230
248
  def check(name, target)
231
249
  Applitools::ArgumentGuard.is_a? target, 'target', Applitools::Selenium::Target
232
250
  original_overflow = nil
@@ -301,6 +319,10 @@ module Applitools::Selenium
301
319
  end
302
320
  end
303
321
 
322
+ # Validates the contents of an iframe and matches it with the expected output.
323
+ #
324
+ # @param [Hash] options The specific parameters of the desired screenshot.
325
+ # @option options [Array] :target_frames The frames to check.
304
326
  def check_in_frame(options)
305
327
  frames = options.delete :target_frames
306
328
 
@@ -323,6 +345,10 @@ module Applitools::Selenium
323
345
  driver.switch_to.frames frame_chain: original_frame_chain
324
346
  end
325
347
 
348
+ # Creates a region instance.
349
+ #
350
+ # @param [Applitools::Element] element The element.
351
+ # @return [Applitools::Region] The relevant region.
326
352
  def region_for_element(element)
327
353
  return element if element.is_a? Applitools::Region
328
354
 
@@ -342,6 +368,9 @@ module Applitools::Selenium
342
368
  )
343
369
  end
344
370
 
371
+ # Returns the region of a given iframe.
372
+ #
373
+ # @return [Applitools::Region] The region of the iframe.
345
374
  def region_provider_for_frame
346
375
  Object.new.tap do |provider|
347
376
  current_frame_size = lambda do
@@ -375,6 +404,7 @@ module Applitools::Selenium
375
404
 
376
405
  # Takes a snapshot of the application under test and matches a region of
377
406
  # a specific element with the expected region output.
407
+ #
378
408
  # @param [Applitools::Selenium::Element] element Represents a region to check.
379
409
  # @param [Symbol] how a finder, such :css or :id. Selects a finder will be used to find an element
380
410
  # See Selenium::Webdriver::Element#find_element documentation for full list of possible finders.
@@ -401,6 +431,14 @@ module Applitools::Selenium
401
431
  end
402
432
  end
403
433
 
434
+ # Validates the contents of an iframe and matches it with the expected output.
435
+ #
436
+ # @param [Hash] options The specific parameters of the desired screenshot.
437
+ # @option options [Fixnum] :timeout The amount of time to retry matching. (Seconds)
438
+ # @option options [String] :tag An optional tag to be associated with the snapshot.
439
+ # @option options [String] :frame_key The key of the relevant frame.
440
+ # @option options [String] :name_or_id The name or id of the screenshot.
441
+ # @return [Applitools::MatchResult] The match results.
404
442
  def check_frame(options = {})
405
443
  options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge!(options)
406
444
 
@@ -417,8 +455,15 @@ module Applitools::Selenium
417
455
  end
418
456
  end
419
457
 
420
- # @param [hash] options
421
- # @option options []
458
+ # Validates the contents of a region in an iframe and matches it with the expected output.
459
+ #
460
+ # @param [Hash] options The specific parameters of the desired screenshot.
461
+ # @option options [String] :name_or_id The name or id of the frame.
462
+ # @option options [String] :tag An optional tag to be associated with the snapshot.
463
+ # @option options [Symbol] :by By which identifier to find the region (e.g :css, :id).
464
+ # @option options [Fixnum] :timeout The amount of time to retry matching. (Seconds)
465
+ # @option options [Boolean] :stitch_content Whether to stitch the content or not.
466
+ # @return [Applitools::MatchResult] The match results.
422
467
  def check_region_in_frame(options = {})
423
468
  options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil, stitch_content: false }.merge!(options)
424
469
  Applitools::ArgumentGuard.not_nil options[:by], 'options[:by]'
@@ -472,14 +517,17 @@ module Applitools::Selenium
472
517
  end
473
518
  end
474
519
 
475
- # @param [Hash] options
476
- # @option [Fixnum] :index
477
- # @option [String] :name_or_id
478
- # @option [Applitools::Selenium::Element] :frame_element
520
+ # Validates the contents of an iframe and matches it with the expected output.
521
+ #
522
+ # @param [Hash] options The options.
523
+ # @option [Fixnum] :index The index of the iframe.
524
+ # @option [String] :name_or_id The name or id of the screenshot.
525
+ # @option [Applitools::Selenium::Element] :frame_element The relevant frame.
479
526
  # @option [Array] :frames_path
480
527
  # @option [Applitools::Selenium::FrameChain] :frame_chain
481
- # @option [Fixnum] :timeout
482
- # @option [String] :tag
528
+ # @option [Fixnum] :timeout The amount of time to retry matching. (Seconds)
529
+ # @option [String] :tag An optional tag to be associated with the snapshot.
530
+ # @option [String] :frame_key The key of the relevant frame.
483
531
  def check_frame__(options = {})
484
532
  options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge!(options)
485
533
 
@@ -919,6 +967,7 @@ module Applitools::Selenium
919
967
  end
920
968
 
921
969
  # check a region, specified by element_or_selector parameter
970
+ #
922
971
  # @param [Array] element_or_selector Array, which contains Applitools::Selenium::Element or [:finder, :value]
923
972
  # pair should be used in find_element
924
973
  # @param [Hash] options
@@ -980,6 +1029,7 @@ module Applitools::Selenium
980
1029
  end
981
1030
 
982
1031
  # Checks an element, specified by +element_or_selector+ parameter
1032
+ #
983
1033
  # @param [Array] element_or_selector Array, which contains Applitools::Selenium::Element or [:finder, :value]
984
1034
  # pair should be used in find_element
985
1035
  # @param [Hash] options
@@ -1096,6 +1146,7 @@ module Applitools::Selenium
1096
1146
  end
1097
1147
 
1098
1148
  # Resets screenshot_names sequence to initial state.
1149
+ #
1099
1150
  # @param [Boolean] value should be false or nil to reset the sequence. Takes no effect if +true+ passed
1100
1151
  def screenshot_name_enumerator=(value)
1101
1152
  @name_enumerator = nil unless value
@@ -6,6 +6,11 @@ module Applitools::Selenium
6
6
 
7
7
  attr_reader :driver, :on_will_switch, :scroll_position_provider
8
8
 
9
+ # Initialize a class instance.
10
+ #
11
+ # @param [Applitools::Selenium::Driver] driver The wrapped Selenium driver instance.
12
+ # @param [Applitools::Selenium::EyesTargetLocator] original_target_locator The target locator.
13
+ # @param [FrameChangeEventListener] on_will_switch
9
14
  def initialize(driver, original_target_locator, on_will_switch)
10
15
  super(original_target_locator)
11
16
  @driver = driver
@@ -13,11 +18,12 @@ module Applitools::Selenium
13
18
  @scroll_position_provider = Applitools::Selenium::ScrollPositionProvider.new(driver)
14
19
  end
15
20
 
16
- # @param [Hash] options
17
- # @option options [Fixnum] :index
18
- # @option options [String] :name_or_id
19
- # @option options [WebElement] :frameElement
20
- # @return [Applitools::Selenium::Driver]
21
+ # Set a certain iframe.
22
+ #
23
+ # @param [Hash] options The possible options.
24
+ # @option options [Fixnum] :index The index of the frame.
25
+ # @option options [String] :name_or_id The name of the frame.
26
+ # @option options [WebElement] :frameElement The element with the frame.
21
27
  def frame(options = {})
22
28
  raise Applitools::EyesIllegalArgument.new 'You must pass :index or :name_or_id or :frame_element option' unless
23
29
  options[:index] || options[:name_or_id] || options[:frame_element]
@@ -29,6 +35,9 @@ module Applitools::Selenium
29
35
  end
30
36
  end
31
37
 
38
+ # Switches to parent frame.
39
+ #
40
+ # @return [Applitools::Selenium::Driver] The wrapped Selenium driver instance.
32
41
  def parent_frame
33
42
  logger.info 'EyesTargetLocator.parent_frame()'
34
43
  unless driver.frame_chain.empty?
@@ -40,10 +49,11 @@ module Applitools::Selenium
40
49
  driver
41
50
  end
42
51
 
43
- # @param [hash] options
44
- # @option options [Applitools::Selenium::FrameChain] :frame_chain
45
- # @option options [String] :frames_path
46
- # @return Applitools::Selenium::Driver
52
+ # Sets several frames.
53
+ #
54
+ # @param [hash] options The options for the frames.
55
+ # @option options [Applitools::Selenium::FrameChain] :frame_chain The frame chain.
56
+ # @option options [String] :frames_path The frames paths.
47
57
  def frames(options = {})
48
58
  raise Applitools::EyesIllegalArgument.new 'You must pass :frame_chain or :frames_path' if
49
59
  options[:frame_chain].nil? & options[:frames_path].nil?
@@ -56,7 +66,9 @@ module Applitools::Selenium
56
66
  end
57
67
  end
58
68
 
59
- # A wrapper for the native method +default_content+
69
+ # A wrapper for the native method +default_content+.
70
+ #
71
+ # @return [Applitools::Selenium::Driver] The wrapped Selenium driver instance.
60
72
  def default_content
61
73
  logger.info 'EyesTargetLocator.default_content()'
62
74
  unless driver.frame_chain.empty?
@@ -69,7 +81,9 @@ module Applitools::Selenium
69
81
  driver
70
82
  end
71
83
 
72
- # A wrapper for the native method +window+
84
+ # A wrapper for the native method +window+.
85
+ #
86
+ # @return [Applitools::Selenium::Driver] The wrapped Selenium driver instance.
73
87
  def window(name_or_handle)
74
88
  logger.info 'EyesTargetLocator.window()'
75
89
  logger.info 'Making preparaions...'
@@ -80,7 +94,9 @@ module Applitools::Selenium
80
94
  driver
81
95
  end
82
96
 
83
- # A wrapper for the native method +active_element+
97
+ # A wrapper for the native method +active_element+.
98
+ #
99
+ # @return [Applitools::Selenium::Element] The wrapped Selenium element instance.
84
100
  def active_element
85
101
  logger.info 'EyesTargetLocator.active_element()'
86
102
  logger.info 'Switching to element...'
@@ -98,7 +114,9 @@ module Applitools::Selenium
98
114
  result
99
115
  end
100
116
 
101
- # A wrapper for a native method +alert+
117
+ # A wrapper for a native method +alert+.
118
+ #
119
+ # @return [Applitools::Selenium::EyesTargetLocator] The result .
102
120
  def alert
103
121
  logger.info 'EyesTargetLocator.alert()'
104
122
  logger.info 'Switching to alert...'
@@ -22,6 +22,10 @@ module Applitools::Selenium
22
22
  class << self
23
23
  alias _new new
24
24
 
25
+ # Creates new image.
26
+ #
27
+ # @param [Array] *args The arguments.
28
+ # @return [Applitools::Screenshot] The image.
25
29
  def new(*args)
26
30
  image = args.shift
27
31
  raise Applitools::EyesIllegalArgument.new 'image is expected to be Applitools::Screenshot!' unless
@@ -37,6 +41,12 @@ module Applitools::Selenium
37
41
  raise Applitools::EyesIllegalArgument.new "#{self.class}.initialize(): Hash is expected as an argument!"
38
42
  end
39
43
 
44
+ # Calculates the frame location in the screenshot.
45
+ #
46
+ # @param [Applitools::Selenium::FrameChain] frame_chain The driver's frame chain.
47
+ # @param [String] screenshot_type The type of the screenshot.
48
+ # @param [Logger] logger The logger instance.
49
+ # @return [Applitools::Location] The location in the screenshot.
40
50
  def calc_frame_location_in_screenshot(frame_chain, screenshot_type, logger)
41
51
  frame_chain = Applitools::Selenium::FrameChain.new other: frame_chain
42
52
  logger.info 'Getting first frame...'
@@ -64,6 +74,13 @@ module Applitools::Selenium
64
74
  end
65
75
  end
66
76
 
77
+ # Initialize element.
78
+ #
79
+ # @param [Hash] options The options.
80
+ # @option options [Symbol] :driver Applitools driver instance.
81
+ # @option options [Symbol] :entire_frame_size The size of the entire frame.
82
+ # @option options [Symbol] :entire_frame The frame instance.
83
+ # @option options [Symbol] :frame_location_in_screenshot The location of the frame in the screenshot.
67
84
  def initialize_for_element(options = {})
68
85
  Applitools::ArgumentGuard.not_nil options[:driver], 'options[:driver]'
69
86
  Applitools::ArgumentGuard.not_nil options[:entire_frame_size], 'options[:entire_frame_size]'
@@ -78,6 +95,16 @@ module Applitools::Selenium
78
95
  self.frame_window = Applitools::Region.new(0, 0, entire_frame_size.width, entire_frame_size.height)
79
96
  end
80
97
 
98
+ # Initializes class properties.
99
+ #
100
+ # @param [Hash] options The options.
101
+ # @option options [Symbol] :driver Wrapped Selenium driver instance.
102
+ # @option options [Symbol] :position_provider The ScrollPositionProvider.
103
+ # @option options [Symbol] :viewport The viewport instance.
104
+ # @option options [Symbol] :entire_frame The entire frame instance.
105
+ # @option options [Symbol] :screenshot_type The screenshot type.
106
+ # @option options [Symbol] :frame_location_in_screenshot The frame location in the screenshot.
107
+ # @option options [Symbol] :force_offset Whether to force offset or not.
81
108
  def initialize_main(options = {})
82
109
  # options = {screenshot_type: SCREENSHOT_TYPES[:viewport]}.merge options
83
110
 
@@ -150,6 +177,12 @@ module Applitools::Selenium
150
177
  # end
151
178
  # end
152
179
 
180
+ # Convert the location.
181
+ #
182
+ # @param [Applitools::Location] location.
183
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] from Source.
184
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] to Destination.
185
+ # @return [Applitools::Location] The converted location.
153
186
  def convert_location(location, from, to)
154
187
  Applitools::ArgumentGuard.not_nil location, 'location'
155
188
  Applitools::ArgumentGuard.not_nil from, 'from'
@@ -197,6 +230,14 @@ module Applitools::Selenium
197
230
  Applitools::Selenium::FrameChain.new other: @frame_chain
198
231
  end
199
232
 
233
+ # Returns the intersected region.
234
+ #
235
+ # @param [Applitools::Selenium::Region] region The relevant region.
236
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] original_coordinate_types The type of
237
+ # the original coordinates.
238
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] result_coordinate_types The type of the
239
+ # original coordinates.
240
+ # @return [Applitools::Region] The intersected region.
200
241
  def intersected_region(region, original_coordinate_types, result_coordinate_types)
201
242
  return Applitools::Region::EMPTY if region.empty?
202
243
  intersected_region = convert_region_location(
@@ -223,6 +264,11 @@ module Applitools::Selenium
223
264
  )
224
265
  end
225
266
 
267
+ # Returns the location in the screenshot.
268
+ #
269
+ # @param [Applitools::Location] location The location.
270
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] coordinate_type The type of the coordinate.
271
+ # @return [Applitools::Location] The location instance in the screenshot.
226
272
  def location_in_screenshot(location, coordinate_type)
227
273
  location = convert_location(
228
274
  location, coordinate_type, Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is]
@@ -235,6 +281,12 @@ module Applitools::Selenium
235
281
  location
236
282
  end
237
283
 
284
+ # Gets a sub-screenshot of a region.
285
+ #
286
+ # @param [Applitools::Region] region The relevant region for taking screenshot.
287
+ # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] coordinate_type The coordinate type.
288
+ # @param [Boolean] throw_if_clipped Whether to throw if screenshot is out of bounds.
289
+ # @return [Applitools::Screenshot] The sub screenshot.
238
290
  def sub_screenshot(region, coordinate_type, throw_if_clipped = false, force_nil_if_clipped = false)
239
291
  logger.info "get_subscreenshot(#{region}, #{coordinate_type}, #{throw_if_clipped})"
240
292
  Applitools::ArgumentGuard.not_nil region, 'region'
@@ -53,6 +53,9 @@ module Applitools::Selenium
53
53
  @frames.last
54
54
  end
55
55
 
56
+ # Returns the default content scroll position.
57
+ #
58
+ # @return [Applitools::Base::Point] The coordinates of the result.
56
59
  def default_content_scroll_position
57
60
  raise NoFramesException.new 'No frames!' if @frames.empty?
58
61
  result = @frames.first.parent_scroll_position
@@ -7,6 +7,18 @@ module Applitools::Selenium
7
7
  MAX_SCROLL_BAR_SIZE = 50
8
8
  MIN_SCREENSHOT_PART_HEIGHT = 10
9
9
 
10
+ # Returns the stitched image.
11
+ #
12
+ # @param [Hash] options The options.
13
+ # @option [Applitools::Selenium::TakesScreenshotImageProvider] :image_provider
14
+ # @option [Applitools::Region] :region_to_check
15
+ # @option [Applitools::Selenium::ScrollPositionProvider] :origin_provider
16
+ # @option [Applitools::Selenium::ElementPositionProvider] :position_provider
17
+ # @option [Applitools::Selenium::ContextBasedScaleProvider] :scale_provider
18
+ # @option [Applitools::FixedCutProvider] :cut_provider
19
+ # @option [Integer] :wait_before_screenshots The time to wait before taking screenshot.
20
+ # @option [Faraday::Request::UrlEncoded] :eyes_screenshot_factory The images.
21
+ # @return [Applitools::Image] The entire image.
10
22
  def get_stiched_region(options = {})
11
23
  logger.info 'get_stiched_region() has been invoked.'
12
24
  image_provider = options[:image_provider]
@@ -3,11 +3,18 @@ module Applitools::Selenium
3
3
  class Keyboard
4
4
  attr_reader :keyboard, :driver
5
5
 
6
+ # Creates a new Applitools::Selenium::Keyboard instance.
7
+ #
8
+ # @param [Applitools::Selenium::Driver] driver The driver instance.
9
+ # @param [Selenium::WebDriver::Keyboard] keyboard The keyboard instance.
6
10
  def initialize(driver, keyboard)
7
11
  @driver = driver
8
12
  @keyboard = keyboard
9
13
  end
10
14
 
15
+ # Types the keys into a text box.
16
+ #
17
+ # @param [Array] *keys The keys to type into the text box.
11
18
  def send_keys(*keys)
12
19
  active_element = Applitools::Selenium::Element.new(driver, driver.switch_to.active_element)
13
20
  current_control = active_element.region
@@ -17,10 +24,16 @@ module Applitools::Selenium
17
24
  keyboard.send_keys(*keys)
18
25
  end
19
26
 
27
+ # Press the key.
28
+ #
29
+ # @param [String] key The key to press.
20
30
  def press(key)
21
31
  keyboard.press(key)
22
32
  end
23
33
 
34
+ # Release the key.
35
+ #
36
+ # @param [String] key The key to release.
24
37
  def release(key)
25
38
  keyboard.release(key)
26
39
  end
@@ -3,6 +3,10 @@ module Applitools::Selenium
3
3
  class Mouse
4
4
  attr_reader :driver, :mouse
5
5
 
6
+ # Creates a new Applitools::Selenium::Mouse instance.
7
+ #
8
+ # @param [Applitools::Selenium::Driver] driver The driver instance.
9
+ # @param [Selenium::WebDriver::Mouse] mouse The mouse instance.
6
10
  def initialize(driver, mouse)
7
11
  @driver = driver
8
12
  @mouse = mouse
@@ -28,6 +32,11 @@ module Applitools::Selenium
28
32
  extract_trigger_and_perform(:up, element)
29
33
  end
30
34
 
35
+ # Moves the mouse to a certain region.
36
+ #
37
+ # @param [Applitools::Selenium::Element] element The element to move the mouse to.
38
+ # @param [Integer] right_by The amount to move to the right.
39
+ # @param [Integer] down_by The amount to move down.
31
40
  def move_to(element, right_by = nil, down_by = nil)
32
41
  element = element.web_element if element.is_a?(Applitools::Selenium::Element)
33
42
  location = element.location
@@ -39,6 +48,10 @@ module Applitools::Selenium
39
48
  mouse.move_to(element, right_by, down_by)
40
49
  end
41
50
 
51
+ # Moves the mouse to a certain point.
52
+ #
53
+ # @param [Integer] right_by The amount to move to the right.
54
+ # @param [Integer] down_by The amount to move down.
42
55
  def move_by(right_by, down_by)
43
56
  right = [0, right_by].max.round
44
57
  down = [0, down_by].max.round
@@ -8,6 +8,12 @@ module Applitools::Selenium
8
8
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
9
9
  attr_accessor :original_position
10
10
 
11
+ # Set the location of the position provider.
12
+ #
13
+ # @param [Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider]
14
+ # position_provider The position provider type (e.g. Applitools::Selenium::CssTranslatePositionProvider,
15
+ # Applitools::Selenium::ScrollPositionProvider).
16
+ # @param [Applitools::Location] location The location to move to.
11
17
  def move_to_region(position_provider, location)
12
18
  logger.info 'Getting current position state...'
13
19
  self.original_position = position_provider.state
@@ -24,6 +30,11 @@ module Applitools::Selenium
24
30
  logger.info 'Done!'
25
31
  end
26
32
 
33
+ # Return the position provider to its original position.
34
+ #
35
+ # @param [Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider]
36
+ # position_provider The position provider type (e.g. Applitools::Selenium::CssTranslatePositionProvider,
37
+ # Applitools::Selenium::ScrollPositionProvider).
27
38
  def return_to_original_position(position_provider)
28
39
  return if original_position.nil?
29
40
  logger.info 'Returning to original position...'
@@ -5,6 +5,11 @@ module Applitools::Selenium
5
5
 
6
6
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
7
7
 
8
+ # Creates a new Applitools::Selenium::ScrollPositionProvider instance.
9
+ #
10
+ # @param [Applitools::Selenium::Driver] executor The instance that of the driver.
11
+ # @param [Boolean] disable_horizontal Whether to disable horizontal movement or not.
12
+ # @param [Boolean] disable_vertical Whether to disable vertical movement or not.
8
13
  def initialize(executor, disable_horizontal = false, disable_vertical = false, max_width: nil, max_height: nil)
9
14
  self.executor = executor
10
15
  self.disable_horizontal = disable_horizontal
@@ -13,7 +18,9 @@ module Applitools::Selenium
13
18
  self.max_height = max_height
14
19
  end
15
20
 
16
- # The scroll position of the current frame
21
+ # The scroll position of the current frame.
22
+ #
23
+ # @return [Applitools::Location] The current position of the ScrollPositionProvider.
17
24
  def current_position
18
25
  logger.info 'current_position()'
19
26
  result = Applitools::Utils::EyesSeleniumUtils.current_scroll_position(executor)
@@ -39,6 +46,9 @@ module Applitools::Selenium
39
46
 
40
47
  alias scroll_to position=
41
48
 
49
+ # Returns the entire size of the viewport.
50
+ #
51
+ # @return [Applitools::RectangleSize] The viewport size.
42
52
  def entire_size
43
53
  viewport_size = Applitools::Utils::EyesSeleniumUtils.extract_viewport_size(executor)
44
54
  result = Applitools::Utils::EyesSeleniumUtils.entire_page_size(executor)
@@ -5,6 +5,13 @@ module Applitools::Selenium
5
5
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
6
6
 
7
7
  attr_accessor :driver, :name_enumerator
8
+
9
+ # Initialize an Applitools::Selenium::TakesScreenshotImageProvider.
10
+ #
11
+ # @param [Applitools::Selenium::Driver] driver
12
+ # @param [Hash] options The options for taking a screenshot.
13
+ # @option options [Boolean] :debug_screenshot
14
+ # @option options [Enumerator] :name_enumerator The name enumerator.
8
15
  def initialize(driver, options = {})
9
16
  self.driver = driver
10
17
  options = { debug_screenshot: false }.merge! options
@@ -12,6 +19,9 @@ module Applitools::Selenium
12
19
  self.name_enumerator = options[:name_enumerator]
13
20
  end
14
21
 
22
+ # Takes a screenshot.
23
+ #
24
+ # @return [Applitools::Screenshot::Datastream] The screenshot.
15
25
  def take_screenshot
16
26
  logger.info 'Getting screenshot...'
17
27
  if debug_screenshot
@@ -13,12 +13,18 @@ module Applitools
13
13
 
14
14
  attr_accessor :element, :frames, :region_to_check, :coordinate_type, :options, :ignored_regions
15
15
 
16
+ # Initialize a Applitools::Selenium::Target instance.
16
17
  def initialize
17
18
  self.frames = []
18
19
  self.options = {}
19
20
  reset_for_fullscreen
20
21
  end
21
22
 
23
+ # Add the wanted ignored regions.
24
+ #
25
+ # @param [Array] *args The arguments to ignore.
26
+ # @option args [String] :name The name of the region to ignore.
27
+ # @option args [Integer] :id The id of the region to ignore.
22
28
  def ignore(*args)
23
29
  if args.first
24
30
  ignored_regions << if args.first.is_a? Applitools::Selenium::Element
@@ -56,6 +62,12 @@ module Applitools
56
62
  self
57
63
  end
58
64
 
65
+ # Add the desired region.
66
+ #
67
+ # @param [Array] *args The arguments to add.
68
+ # @option args [Integer] :timeout The timeout.
69
+ # @option args [Integer] :id The id of the region.
70
+ # @return [Applitools::Selenium::Target] Self instance.
59
71
  def region(*args)
60
72
  self.region_to_check = if args.first.is_a? Applitools::Selenium::Element
61
73
  proc do
@@ -25,6 +25,10 @@ module Applitools::Selenium
25
25
  VERIFY_RETRIES = 3
26
26
  BROWSER_SIZE_CALCULATION_RETRIES = 2
27
27
 
28
+ # Initialize a Applitools::Selenium::ViewportSize instance.
29
+ #
30
+ # @param [Applitools::Selenium::Driver] driver The driver instance.
31
+ # @param [Applitools::Base::Dimension] dimension The dimension of the viewport size.
28
32
  def initialize(driver, dimension = nil)
29
33
  @driver = driver
30
34
  @dimension = dimension.nil? ? nil : setup_dimension(dimension)
@@ -40,6 +44,9 @@ module Applitools::Selenium
40
44
 
41
45
  alias extract_viewport_from_browser! extract_viewport_size!
42
46
 
47
+ # Extract the viewport size.
48
+ #
49
+ # @return [Applitools::Base::Dimension] The dimensions of the viewport size.
43
50
  def extract_viewport_size
44
51
  width = nil
45
52
  height = nil
@@ -64,6 +71,7 @@ module Applitools::Selenium
64
71
  alias viewport_size extract_viewport_size
65
72
  alias extract_viewport_from_browser extract_viewport_size
66
73
 
74
+ # Set the viewport size.
67
75
  def set
68
76
  Applitools::EyesLogger.debug "Set viewport size #{@dimension}"
69
77
  # Before resizing the window, set its position to the upper left corner (otherwise, there might not be enough
@@ -124,7 +132,6 @@ module Applitools::Selenium
124
132
  # tries to resize browser, yields a block (which should check if an attempt was successful) before each iteration.
125
133
  # If the block returns true, stop trying and returns true (resize was successful)
126
134
  # Otherwise, returns false after VERIFY_RETRIES iterations
127
-
128
135
  def resize_attempt
129
136
  actual_viewport_size = extract_viewport_size
130
137
  Applitools::EyesLogger.debug "Actual viewport size #{actual_viewport_size}"
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.6.8'.freeze
2
+ VERSION = '3.6.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.8
4
+ version: 3.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eyes_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.6.8
19
+ version: 3.6.9
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.6.8
26
+ version: 3.6.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement