eyes_selenium 3.10.1 → 3.10.2

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
  SHA1:
3
- metadata.gz: f06722619f30d8f8161191c90e260f3942796534
4
- data.tar.gz: 6cdf3ed4f48197d05086001b133ee60097cd7fcf
3
+ metadata.gz: 15870d2d4f82382cfb5e1a66f0b250203bcf55a4
4
+ data.tar.gz: 1d65c7e9e6ea324b9f31c456836c8e9588db587d
5
5
  SHA512:
6
- metadata.gz: 2cb6db07bd67a7d263f2e5e43ecc040eba9a5754832e7535b54ebdf76ef2711ffa7731dc4e4cac0bc71aa96df8a07dd2de57b6b22fcb382a3f178c6d1929f6d8
7
- data.tar.gz: e860a3b924cbb7f90824ab0b323638a2c00440dc2cca4303bba39a1fafdace7cf43b9bbd86e7579252211385495ee27112b76fceab119a5bf93421a18d407568
6
+ metadata.gz: 880a3ee29beb57e4dd1694d817d44934f1bcccd0576163da8ecf03b262fa43dc907e1033bb93c53eb371ac36848b55fcd2f457cd65fde811ab12ad85d32b135e
7
+ data.tar.gz: '094d8aca9b731dca647045c665a45221326621d2194030ef4f496f67063787e658506093ffc96a14a2940e049c4c24d5096b4054e8fbccfae50bca8aa1895f8d'
@@ -28,7 +28,6 @@ module Applitools::Selenium
28
28
  }.freeze
29
29
 
30
30
  attr_reader :browser
31
- attr_accessor :wait_before_screenshots
32
31
  attr_accessor :rotation
33
32
 
34
33
  def_delegators :@eyes, :add_mouse_trigger, :add_text_trigger
@@ -45,7 +44,6 @@ module Applitools::Selenium
45
44
  def initialize(eyes, options)
46
45
  super(options[:driver])
47
46
  @is_mobile_device = options.fetch(:is_mobile_device, false)
48
- @wait_before_screenshots = 0
49
47
  @eyes = eyes
50
48
  @frame_chain = Applitools::Selenium::FrameChain.new
51
49
  @browser = Applitools::Selenium::Browser.new(self, @eyes)
@@ -122,8 +120,8 @@ module Applitools::Selenium
122
120
  screenshot.to_blob
123
121
  end
124
122
 
125
- # Finds an element, specified by +what+ parameter interpreting it in the way, specified in +how+ parameter
126
- # @param [Symbol] how Defines the way that +what+ parameter will be interpreted (The type of selector). Can be one
123
+ # Finds an element in a window.
124
+ # @param [Symbol] how Defines the way that +what+ parameter will be interpreted (finder). Can be one
127
125
  # of: +:class+, +:class_name+, +:css+, +:id+, +:link+, +:link_text+, +:name+, +:partial_link_text+, +:tag_name+,
128
126
  # +:xpath+
129
127
  # @param [String] what The selector to find an element
@@ -137,11 +135,6 @@ module Applitools::Selenium
137
135
  # @return [Applitools::Selenium::Element]
138
136
  # @!parse def find_element(how, what); end
139
137
 
140
- # Finds an element in a window.
141
- #
142
- # @param [Array] *args The arguments for finding the element (at most contains 2 params).
143
- # @option args [Symbol] :by By what means to search for the element (e.g. :css, :id).
144
- # @option args [String] Name of element.
145
138
  def find_element(*args)
146
139
  how, what = extract_args(args)
147
140
 
@@ -151,8 +144,8 @@ module Applitools::Selenium
151
144
  Applitools::Selenium::Element.new(self, driver.find_element(how, what))
152
145
  end
153
146
 
154
- # Finds elements, specified by +what+ parameter interpreting it in the way, specified in +how+ parameter
155
- # @param [Symbol] how Defines the way that +what+ parameter will be interpreted (The type of selector). Can be one
147
+ # Finds elements in a window.
148
+ # @param [Symbol] how Defines the way that +what+ parameter will be interpreted (finder). Can be one
156
149
  # of: +:class+, +:class_name+, +:css+, +:id+, +:link+, +:link_text+, +:name+, +:partial_link_text+, +:tag_name+,
157
150
  # +:xpath+
158
151
  # @param [String] what The selector to find an element
@@ -166,11 +159,6 @@ module Applitools::Selenium
166
159
  # @return [ [Applitools::Selenium::Element] ]
167
160
  # @!parse def find_elements(how, what); end
168
161
 
169
- # Finds elements in a window.
170
- #
171
- # @param [Array] *args The arguments for finding the element (at most contains 2 params).
172
- # @option args [Symbol] :by By what means to search for the element (e.g. :css, :id).
173
- # @option args [String] Name of elements.
174
162
  def find_elements(*args)
175
163
  how, what = extract_args(args)
176
164
 
@@ -67,9 +67,8 @@ module Applitools::Selenium
67
67
  alias eql? ==
68
68
 
69
69
  # Types content into text box.
70
- #
71
- # @param [Array] *args The arguments.
72
- # @option *args [String] The content to type.
70
+ # @param [Array, String] keys The content to type.
71
+ # @!parse def send_keys(keys); end;
73
72
  def send_keys(*args)
74
73
  Selenium::WebDriver::Keys.encode(args).each do |key|
75
74
  @driver.add_text_trigger(self, key.to_s)
@@ -11,12 +11,6 @@ module Applitools::Selenium
11
11
 
12
12
  USE_DEFAULT_MATCH_TIMEOUT = -1
13
13
 
14
- # @!visibility private
15
- STICH_MODE = {
16
- :scroll => :SCROLL,
17
- :css => :CSS
18
- }.freeze
19
-
20
14
  extend Forwardable
21
15
  # @!visibility public
22
16
 
@@ -24,7 +18,7 @@ module Applitools::Selenium
24
18
  def eyes_driver(driver, eyes = nil)
25
19
  if driver.respond_to? :driver_for_eyes
26
20
  driver.driver_for_eyes eyes
27
- elsif driver.is_a? Capybara::Poltergeist::Driver
21
+ elsif defined?(::Capybara::Poltergeist) && (driver.is_a? ::Capybara::Poltergeist::Driver)
28
22
  Applitools::Poltergeist::Driver.new(eyes, driver: driver)
29
23
  else
30
24
  unless driver.is_a?(Applitools::Selenium::Driver)
@@ -99,7 +93,7 @@ module Applitools::Selenium
99
93
  self.dont_get_title = false
100
94
  self.hide_scrollbars = false
101
95
  self.device_pixel_ratio = UNKNOWN_DEVICE_PIXEL_RATIO
102
- self.stitch_mode = STICH_MODE[:scroll]
96
+ self.stitch_mode = Applitools::STITCH_MODE[:scroll]
103
97
  self.wait_before_screenshots = DEFAULT_WAIT_BEFORE_SCREENSHOTS
104
98
  self.region_visibility_strategy = MoveToRegionVisibilityStrategy.new
105
99
  self.debug_screenshot = false
@@ -134,21 +128,7 @@ module Applitools::Selenium
134
128
  end
135
129
 
136
130
  @driver = self.class.eyes_driver(driver, self)
137
-
138
- # if driver.respond_to? :driver_for_eyes
139
- # @driver = driver.driver_for_eyes self
140
- # elsif driver.is_a? Capybara::Poltergeist::Driver
141
- # @driver = Applitools::Poltergeist::Driver.new(self, driver: driver)
142
- # else
143
- # unless driver.is_a?(Applitools::Selenium::Driver)
144
- # logger.warn("Unrecognized driver type: (#{driver.class.name})!")
145
- # is_mobile_device = driver.respond_to?(:capabilities) && driver.capabilities['platformName']
146
- # @driver = Applitools::Selenium::Driver.new(self, driver: driver, is_mobile_device: is_mobile_device)
147
- # end
148
- # end
149
-
150
131
  self.device_pixel_ratio = UNKNOWN_DEVICE_PIXEL_RATIO
151
-
152
132
  self.position_provider = self.class.position_provider(
153
133
  stitch_mode, driver, disable_horizontal_scrolling, disable_vertical_scrolling, explicit_entire_size
154
134
  )
@@ -170,13 +150,17 @@ module Applitools::Selenium
170
150
  # @option value [Symbol] :scroll Scroll to perform stitching.
171
151
  # @return [Symbol] The type of stitching.
172
152
  def stitch_mode=(value)
173
- @stitch_mode = value.to_s.upcase == STICH_MODE[:css].to_s ? STICH_MODE[:css] : STICH_MODE[:scroll]
153
+ @stitch_mode = if value.to_s.upcase == Applitools::STITCH_MODE[:css].to_s
154
+ Applitools::STITCH_MODE[:css]
155
+ else
156
+ Applitools::STITCH_MODE[:scroll]
157
+ end
174
158
  unless driver.nil?
175
159
  self.position_provider = self.class.position_provider(
176
160
  stitch_mode, driver, disable_horizontal_scrolling, disable_vertical_scrolling, explicit_entire_size
177
161
  )
178
162
  end
179
- if stitch_mode == STICH_MODE[:css]
163
+ if stitch_mode == Applitools::STITCH_MODE[:css]
180
164
  @css_transition_original_hide_scrollbars = hide_scrollbars
181
165
  self.hide_scrollbars = true
182
166
  else
@@ -190,39 +174,10 @@ module Applitools::Selenium
190
174
  # @param [String] tag An optional tag to be assosiated with the snapshot.
191
175
  # @param [Fixnum] match_timeout The amount of time to retry matching (seconds)
192
176
  def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
193
- self.tag_for_debug = tag
194
- self.screenshot_name_enumerator = nil
195
- if disabled?
196
- logger.info "check_window(#{tag}, #{match_timeout}): Ignored"
197
- return
198
- end
199
-
200
- logger.info "check_window(match_timeout: #{match_timeout}, tag: #{tag}): Ignored" if disabled?
201
- logger.info "check_window(match_timeout: #{match_timeout}, tag: #{tag})"
202
-
203
- region_provider = Object.new
204
- region_provider.instance_eval do
205
- define_singleton_method :region do
206
- Applitools::Region::EMPTY
207
- end
208
- define_singleton_method :coordinate_type do
209
- nil
210
- end
211
- end
212
-
213
- self.eyes_screenshot_factory = lambda do |image|
214
- Applitools::Selenium::EyesWebDriverScreenshot.new(
215
- image, driver: driver, force_offset: position_provider.force_offset
216
- )
217
- end
218
-
219
- match_data = Applitools::MatchWindowData.new.tap do |d|
220
- d.tag = tag
221
- d.ignore_mismatch = false
222
- d.match_level = default_match_settings[:match_level]
177
+ target = Applitools::Selenium::Target.window.tap do |t|
178
+ t.timeout(match_timeout)
223
179
  end
224
-
225
- check_window_base region_provider, match_timeout, match_data
180
+ check(tag, target)
226
181
  end
227
182
 
228
183
  # @!visibility private
@@ -246,11 +201,14 @@ module Applitools::Selenium
246
201
  # @param [Applitools::Selenium::Target] target which area of the window to check.
247
202
  # @return [Applitools::MatchResult] The match results.
248
203
  def check(name, target)
204
+ logger.info "check(#{name}) is called"
205
+ self.tag_for_debug = name
249
206
  Applitools::ArgumentGuard.is_a? target, 'target', Applitools::Selenium::Target
250
207
  original_overflow = nil
251
208
  original_position_provider = position_provider
252
209
 
253
210
  eyes_element = nil
211
+ timeout = target.options[:timeout] || USE_DEFAULT_MATCH_TIMEOUT
254
212
 
255
213
  self.eyes_screenshot_factory = lambda do |image|
256
214
  Applitools::Selenium::EyesWebDriverScreenshot.new(
@@ -262,6 +220,7 @@ module Applitools::Selenium
262
220
  begin
263
221
  match_data = Applitools::MatchWindowData.new
264
222
  match_data.tag = name
223
+ update_default_settings(match_data)
265
224
  match_data.read_target(target, driver)
266
225
  eyes_element = target.region_to_check.call(driver)
267
226
  region_visibility_strategy.move_to_region original_position_provider,
@@ -270,16 +229,19 @@ module Applitools::Selenium
270
229
  check_window = false
271
230
  if !target.frames.empty? && eyes_element.is_a?(Applitools::Region)
272
231
  # check_current_frame
232
+ logger.info "check_region_in_frame(#{eyes_element})"
273
233
  region_provider = region_provider_for_frame
274
234
 
275
235
  elsif eyes_element.is_a? Applitools::Selenium::Element
276
236
  # check_element
237
+ logger.info 'check_region(' \
238
+ "#{Applitools::Region.from_location_size(eyes_element.location, eyes_element.size)})"
277
239
  region_provider = Applitools::RegionProvider.new(
278
- region_for_element(eyes_element),
279
- target.coordinate_type
240
+ region_for_element(eyes_element), target.coordinate_type
280
241
  )
281
242
  else
282
243
  # check_window
244
+ logger.info "check_window(match_timeout: #{timeout}, tag: #{match_data.tag})"
283
245
  region_provider = Applitools::RegionProvider.new(
284
246
  region_for_element(eyes_element),
285
247
  target.coordinate_type
@@ -305,7 +267,7 @@ module Applitools::Selenium
305
267
  end
306
268
 
307
269
  check_window_base(
308
- region_provider, target.options[:timeout] || USE_DEFAULT_MATCH_TIMEOUT, match_data
270
+ region_provider, timeout, match_data
309
271
  )
310
272
  ensure
311
273
  eyes_element.overflow = original_overflow unless original_overflow.nil?
@@ -421,13 +383,11 @@ module Applitools::Selenium
421
383
  # stitch_content: false)
422
384
  # @!parse def check_region(element, how=nil, what=nil, options = {}); end
423
385
  def check_region(*args)
424
- options = Applitools::Utils.extract_options! args
386
+ options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.extract_options!(args)
387
+ target = Applitools::Selenium::Target.new.region(*args).timeout(options[:match_timeout])
388
+ target.fully if options[:stitch_content]
425
389
  self.screenshot_name_enumerator = nil
426
- if options.delete(:stitch_content)
427
- check_element args, options
428
- else
429
- check_region_ args, options
430
- end
390
+ check(options[:tag], target)
431
391
  end
432
392
 
433
393
  # Validates the contents of an iframe and matches it with the expected output.
@@ -435,29 +395,24 @@ module Applitools::Selenium
435
395
  # @param [Hash] options The specific parameters of the desired screenshot.
436
396
  # @option options [Fixnum] :timeout The amount of time to retry matching. (Seconds)
437
397
  # @option options [String] :tag An optional tag to be associated with the snapshot.
438
- # @option options [String] :frame_key The key of the relevant frame.
439
- # @option options [String] :name_or_id The name or id of the screenshot.
398
+ # @option options [String] :frame Frame element or frame name or frame id.
399
+ # @option options [String] :name_or_id The name or id of the target frame (deprecated. use :frame instead).
400
+ # @option options [String] :frame_element The frame element (deprecated. use :frame instead).
440
401
  # @return [Applitools::MatchResult] The match results.
402
+
441
403
  def check_frame(options = {})
442
404
  options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge!(options)
443
-
444
- process_in_frame options do |opts, frame_key|
445
- if disabled?
446
- logger.info "check_frame(#{frame_key}: #{opts[frame_key]}, timeout: #{opts[:timeout]}, " \
447
- "tag: #{opts[:tag]}): Ignored"
448
- return
449
- end
450
-
451
- logger.info "check_frame(#{frame_key}: #{opts[frame_key]}, timeout: #{opts[:timeout]}, " \
452
- "tag: #{opts[:tag]})"
453
- check_current_frame opts[:timeout], opts[:tag]
454
- end
405
+ frame = options[:frame] || options[:frame_element] || options[:name_or_id]
406
+ target = Applitools::Selenium::Target.frame(frame).timeout(options[:timeout]).fully
407
+ check(options[:tag], target)
455
408
  end
456
409
 
457
410
  # Validates the contents of a region in an iframe and matches it with the expected output.
458
411
  #
459
412
  # @param [Hash] options The specific parameters of the desired screenshot.
460
- # @option options [String] :name_or_id The name or id of the frame.
413
+ # @option options [String] :name_or_id The name or id of the target frame (deprecated. use :frame instead).
414
+ # @option options [String] :frame_element The frame element (deprecated. use :frame instead).
415
+ # @option options [String] :frame Frame element or frame name or frame id.
461
416
  # @option options [String] :tag An optional tag to be associated with the snapshot.
462
417
  # @option options [Symbol] :by By which identifier to find the region (e.g :css, :id).
463
418
  # @option options [Fixnum] :timeout The amount of time to retry matching. (Seconds)
@@ -469,16 +424,14 @@ module Applitools::Selenium
469
424
  Applitools::ArgumentGuard.is_a? options[:by], 'options[:by]', Array
470
425
 
471
426
  how_what = options.delete(:by)
427
+ frame = options[:frame] || options[:frame_element] || options[:name_or_id]
472
428
 
473
- process_in_frame options do |opts, frame_key|
474
- if disabled?
475
- logger.info "check_region_in_frame(#{frame_key}: #{options[frame_key]}, by: #{options[:by]}, " \
476
- "timeout: #{options[:timeout]}, tag: #{options[:tag]}): Ignored)"
477
- return
478
- end
429
+ target = Applitools::Selenium::Target.new.timeout(options[:timeout])
430
+ target.frame(frame) if frame
431
+ target.fully if options[:stitch_content]
432
+ target.region(*how_what)
479
433
 
480
- check_region(*how_what, tag: opts[:tag], timeout: opts[:timeout], stitch_content: opts[:stitch_content])
481
- end
434
+ check(options[:tag], target)
482
435
  end
483
436
 
484
437
  # @!parse def check_region(element, how=nil, what=nil, options = {}); end
@@ -516,143 +469,12 @@ module Applitools::Selenium
516
469
  end
517
470
  end
518
471
 
519
- # Validates the contents of an iframe and matches it with the expected output.
520
- #
521
- # @param [Hash] options The options.
522
- # @option [Fixnum] :index The index of the iframe.
523
- # @option [String] :name_or_id The name or id of the screenshot.
524
- # @option [Applitools::Selenium::Element] :frame_element The relevant frame.
525
- # @option [Array] :frames_path
526
- # @option [Applitools::Selenium::FrameChain] :frame_chain
527
- # @option [Fixnum] :timeout The amount of time to retry matching. (Seconds)
528
- # @option [String] :tag An optional tag to be associated with the snapshot.
529
- # @option [String] :frame_key The key of the relevant frame.
530
- def check_frame__(options = {})
531
- options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge!(options)
532
-
533
- unless options[:index] ||
534
- options[:name_or_id] ||
535
- options[:frame_element] ||
536
- options[:frame_chain] ||
537
- options[:frames_path]
538
- raise Applitools::EyesIllegalArgument.new 'You must pass :index or :name_or_id or :frame_element option' \
539
- ' or :frame_chain option or :frames_path option'
540
- end
541
-
542
- if (needed_keys = (options.keys & [:index, :name_or_id, :frame_element, :frame_chain, :frames_path])).length == 1
543
- frame_key = needed_keys.first
544
- else
545
- raise Applitools::EyesIllegalArgument.new 'You\'ve passed some extra keys!' \
546
- 'Only one of :index, :name_or_id or :frame_elenent or :frame_chain or :frames_path is allowed.'
547
- end
548
-
549
- if disabled?
550
- logger.info "check_frame(#{frame_key}: #{options[frame_key]}, timeout: #{options[:timeout]}," \
551
- " tag: #{options[:tag]}): Ignored"
552
- return
553
- end
554
-
555
- frame_or_frames = options[frame_key]
556
- if frame_or_frames.respond_to? :pop
557
- frame_to_check = frame_or_frames.pop
558
- original_frame_chain = driver.frame_chain
559
- logger.info 'Switching to parent frame according to frames path...'
560
- driver.switch_to.frames(frame_key => frame_or_frames)
561
- logger.info 'Done!'
562
- case frame_to_check
563
- when String
564
- frame_options = { name_or_id: frame_to_check }
565
- when Applitools::Selenium::Element
566
- frame_options = { frame_element: frame_to_check }
567
- else
568
- raise Applitools::EyesError.new "Unknown frame class: #{frame_to_check.class}"
569
- end
570
- else
571
- frame_options = { frame_key => options[frame_key] }
572
- end
573
-
574
- logger.info "check_frame(#{frame_key}: #{options[frame_key]}, timeout: #{options[:timeout]}," /
575
- " tag: #{options[:tag]})"
576
- logger.info 'Switching to requested frame...'
577
-
578
- driver.switch_to.frame frame_options
579
- logger.info 'Done!'
580
-
581
- check_current_frame options[:timeout], options[:tag]
582
-
583
- logger.info 'Switching back to parent_frame...'
584
- driver.switch_to.parent_frame
585
- logger.info 'Done!'
586
- return unless original_frame_chain
587
-
588
- logger.info 'Switching back into original frame...'
589
- driver.switch_to.frames frame_chain: original_frame_chain
590
- end
591
-
592
472
  private
593
473
 
594
474
  attr_accessor :check_frame_or_element, :region_to_check, :dont_get_title,
595
475
  :device_pixel_ratio, :position_provider, :scale_provider, :tag_for_debug,
596
476
  :region_visibility_strategy, :eyes_screenshot_factory
597
477
 
598
- def process_in_frame(options = {})
599
- unless options[:index] ||
600
- options[:name_or_id] ||
601
- options[:frame_element] ||
602
- options[:frame_chain] ||
603
- options[:frames_path] ||
604
- options[:target_frames]
605
- raise Applitools::EyesIllegalArgument.new 'You must pass :index or :name_or_id or :frame_element option' /
606
- 'or :frame_chain option or :frames_path option'
607
- end
608
-
609
- needed_keys = (
610
- options.keys & [:index, :name_or_id, :frame_element, :frame_chain, :frames_path, :target_frames]
611
- )
612
-
613
- if needed_keys.length == 1
614
- frame_key = needed_keys.first
615
- else
616
- raise Applitools::EyesIllegalArgument.new 'You\'ve passed some extra keys!' /
617
- 'Only one of :index, :name_or_id or :frame_elenent or :frame_chain or :frames_path is allowed.'
618
- end
619
-
620
- frame_or_frames = options[frame_key]
621
- if frame_or_frames.respond_to? :pop
622
- frame_to_check = frame_or_frames.pop
623
- original_frame_chain = driver.frame_chain
624
- logger.info 'Switching to parent frame according to frames path...'
625
- driver.switch_to.frames(frame_key => frame_or_frames)
626
- logger.info 'Done!'
627
- case frame_to_check
628
- when String
629
- frame_options = { name_or_id: frame_to_check }
630
- when Applitools::Selenium::Element
631
- frame_options = { frame_element: frame_to_check }
632
- else
633
- raise Applitools::EyesError.new "Unknown frame class: #{frame_to_check.class}"
634
- end
635
- else
636
- frame_options = { frame_key => options[frame_key] }
637
- end
638
-
639
- logger.info 'Switching to requested frame...'
640
-
641
- driver.switch_to.frame frame_options
642
- logger.info 'Done!'
643
-
644
- yield(options, frame_key) if block_given?
645
-
646
- logger.info 'Switching back to parent_frame...'
647
- driver.switch_to.parent_frame
648
- logger.info 'Done!'
649
-
650
- return unless original_frame_chain
651
-
652
- logger.info 'Switching back into original frame...'
653
- driver.switch_to.frames frame_chain: original_frame_chain
654
- end
655
-
656
478
  def capture_screenshot
657
479
  image_provider = Applitools::Selenium::TakesScreenshotImageProvider.new driver,
658
480
  debug_screenshot: debug_screenshot, name_enumerator: screenshot_name_enumerator
@@ -673,7 +495,7 @@ module Applitools::Selenium
673
495
  logger.info 'Check frame/element requested'
674
496
  algo = Applitools::Selenium::FullPageCaptureAlgorithm.new
675
497
 
676
- entire_frame_or_element = algo.get_stiched_region(
498
+ entire_frame_or_element = algo.get_stitched_region(
677
499
  image_provider: image_provider,
678
500
  region_to_check: region_to_check,
679
501
  origin_provider: position_provider,
@@ -704,7 +526,7 @@ module Applitools::Selenium
704
526
  nil
705
527
  end
706
528
  end
707
- full_page_image = algo.get_stiched_region image_provider: image_provider,
529
+ full_page_image = algo.get_stitched_region image_provider: image_provider,
708
530
  region_to_check: region_provider,
709
531
  origin_provider: Applitools::Selenium::ScrollPositionProvider.new(driver),
710
532
  position_provider: position_provider,
@@ -724,6 +546,7 @@ module Applitools::Selenium
724
546
  ewd_screenshot
725
547
  else
726
548
  logger.info 'Screenshot requested...'
549
+ sleep wait_before_screenshots
727
550
  image = image_provider.take_screenshot
728
551
  scale_provider.scale_image(image) if scale_provider
729
552
  cut_provider.cut(image) if cut_provider
@@ -1033,7 +856,7 @@ module Applitools::Selenium
1033
856
  # pair should be used in find_element
1034
857
  # @param [Hash] options
1035
858
  # @option options [String] :tag
1036
- # @option options [Float] :tmatch_timeout
859
+ # @option options [Float] :match_timeout
1037
860
 
1038
861
  def check_element(element_or_selector, options = {})
1039
862
  selector = element_or_selector if Applitools::Selenium::Driver::FINDERS.keys.include? element_or_selector.first
@@ -22,10 +22,21 @@ module Applitools::Selenium
22
22
  class << self
23
23
  alias _new new
24
24
 
25
+ # rubocop:disable LineLength
25
26
  # Creates new image.
26
27
  #
27
- # @param [Array] *args The arguments.
28
+ # @param [Applitools::Screenshot] image
29
+ # @param [Hash] options
30
+ # @option options [Applitools::Selenium::Driver] :driver Applitools driver instance.
31
+ # @option options [Applitools::RectangleSize] :entire_frame_size The size of the entire frame.
32
+ # @option options [Applitools::Location] :frame_location_in_screenshot The location of the frame in the screenshot.
33
+ # @option options [String] :screenshot_type One of allowed types - 'VIEPORT' or 'ENTIRE_FRAME'
34
+ # @option options [Applitools::Location] :force_offset
35
+
28
36
  # @return [Applitools::Screenshot] The image.
37
+ # @!parse def initialize(image, options); end
38
+ # rubocop:enable LineLength
39
+
29
40
  def new(*args)
30
41
  image = args.shift
31
42
  raise Applitools::EyesIllegalArgument.new 'image is expected to be Applitools::Screenshot!' unless
@@ -79,7 +90,6 @@ module Applitools::Selenium
79
90
  # @param [Hash] options The options.
80
91
  # @option options [Symbol] :driver Applitools driver instance.
81
92
  # @option options [Symbol] :entire_frame_size The size of the entire frame.
82
- # @option options [Symbol] :entire_frame The frame instance.
83
93
  # @option options [Symbol] :frame_location_in_screenshot The location of the frame in the screenshot.
84
94
  def initialize_for_element(options = {})
85
95
  Applitools::ArgumentGuard.not_nil options[:driver], 'options[:driver]'
@@ -169,17 +179,9 @@ module Applitools::Selenium
169
179
  logger.info 'Done!'
170
180
  end
171
181
 
172
- # def scroll_position
173
- # begin
174
- # position_provider.state
175
- # rescue
176
- # Applitools::Location.new(0,0)
177
- # end
178
- # end
179
-
180
182
  # Convert the location.
181
183
  #
182
- # @param [Applitools::Location] location.
184
+ # @param [Applitools::Location] location Location to convert
183
185
  # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] from Source.
184
186
  # @param [Applitools::EyesScreenshot::COORDINATE_TYPES] to Destination.
185
187
  # @return [Applitools::Location] The converted location.
@@ -66,6 +66,10 @@ module Applitools::Selenium
66
66
  @frames.last.size
67
67
  end
68
68
 
69
+ def to_s
70
+ @frames.map(&:to_s).join(', ')
71
+ end
72
+
69
73
  class NoFramesException < RuntimeError; end
70
74
  end
71
75
  end
@@ -19,8 +19,8 @@ module Applitools::Selenium
19
19
  # @option [Integer] :wait_before_screenshots The time to wait before taking screenshot.
20
20
  # @option [Faraday::Request::UrlEncoded] :eyes_screenshot_factory The images.
21
21
  # @return [Applitools::Image] The entire image.
22
- def get_stiched_region(options = {})
23
- logger.info 'get_stiched_region() has been invoked.'
22
+ def get_stitched_region(options = {})
23
+ logger.info 'get_stitched_region() has been invoked.'
24
24
  image_provider = options[:image_provider]
25
25
  region_provider = options[:region_to_check]
26
26
  origin_provider = options[:origin_provider]
@@ -14,7 +14,7 @@ module Applitools::Selenium
14
14
 
15
15
  # Types the keys into a text box.
16
16
  #
17
- # @param [Array] *keys The keys to type into the text box.
17
+ # @param [Array] keys The keys to type into the text box.
18
18
  def send_keys(*keys)
19
19
  active_element = Applitools::Selenium::Element.new(driver, driver.switch_to.active_element)
20
20
  current_control = active_element.region
@@ -1,5 +1,4 @@
1
1
  module Applitools::Selenium
2
- # @!visibility private
3
2
  class MoveToRegionVisibilityStrategy
4
3
  extend Forwardable
5
4
 
@@ -8,12 +7,13 @@ module Applitools::Selenium
8
7
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
9
8
  attr_accessor :original_position
10
9
 
10
+ # rubocop:disable LineLength
11
11
  # Set the location of the position provider.
12
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).
13
+ # @param [Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider] position_provider
14
+ # The position provider type (e.g. Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider).
16
15
  # @param [Applitools::Location] location The location to move to.
16
+ # rubocop:enable LineLength
17
17
  def move_to_region(position_provider, location)
18
18
  logger.info 'Getting current position state...'
19
19
  self.original_position = position_provider.state
@@ -30,11 +30,11 @@ module Applitools::Selenium
30
30
  logger.info 'Done!'
31
31
  end
32
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).
33
+ # rubocop:disable LineLength
34
+ # Returns the position provider to its original position.
35
+ # @param [Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider] position_provider
36
+ # The position provider type (e.g. Applitools::Selenium::CssTranslatePositionProvider, Applitools::Selenium::ScrollPositionProvider).
37
+ # rubocop:enable LineLength
38
38
  def return_to_original_position(position_provider)
39
39
  return if original_position.nil?
40
40
  logger.info 'Returning to original position...'
@@ -28,19 +28,21 @@ module Applitools
28
28
  reset_for_fullscreen
29
29
  end
30
30
 
31
+ # rubocop:disable LineLength
31
32
  # Add the wanted ignored regions.
32
33
  #
33
- # @param [Array] *args The arguments to ignore.
34
- # @option args [String] :name The name of the region to ignore.
35
- # @option args [Integer] :id The id of the region to ignore.
34
+ # @param [Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element] region_or_element the region to ignore or an element representing the region to ignore
35
+ # @param [Symbol, String] how A finder to be used (see Selenium::WebDriver documentation for complete list of available finders)
36
+ # @param [Symbol, String] what An id or selector to find
37
+ # @!parse def ignore(region_or_element, how, what); end;
38
+ # rubocop:enable LineLength
39
+
36
40
  def ignore(*args)
37
41
  if args.empty?
38
42
  reset_ignore
39
43
  else
40
44
  ignored_regions << case args.first
41
- when Applitools::Selenium::Element
42
- proc { args.first }
43
- when Applitools::Region
45
+ when Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element
44
46
  proc { args.first }
45
47
  else
46
48
  proc do |driver|
@@ -56,8 +58,8 @@ module Applitools
56
58
  value = case args.first
57
59
  when Applitools::FloatingRegion
58
60
  proc { args.first }
59
- when Applitools::Selenium::Element
60
- proc { Applitools::FloatingRegion.for_element args.shift, *args }
61
+ when ::Selenium::WebDriver::Element, Applitools::Selenium::Element
62
+ proc { Applitools::FloatingRegion.any args.shift, *args }
61
63
  when Applitools::Region
62
64
  proc do
63
65
  region = args.shift
@@ -65,7 +67,7 @@ module Applitools
65
67
  end
66
68
  else
67
69
  proc do |driver|
68
- Applitools::FloatingRegion.for_element driver.find_element(args.shift, args.shift), *args
70
+ Applitools::FloatingRegion.any driver.find_element(args.shift, args.shift), *args
69
71
  end
70
72
  end
71
73
  floating_regions << value
@@ -83,17 +85,23 @@ module Applitools
83
85
  self
84
86
  end
85
87
 
88
+ # rubocop:disable LineLength
86
89
  # Add the desired region.
87
90
  #
88
- # @param [Array] *args The arguments to add.
89
- # @option args [Integer] :timeout The timeout.
90
- # @option args [Integer] :id The id of the region.
91
- # @return [Applitools::Selenium::Target] Self instance.
91
+ # @param [Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element] element the target region or an element representing the target region
92
+ # @param [Symbol, String] how The finder to be used (:css, :id, etc. see Selenium::WebDriver documentation for complete list of available finders)
93
+ # @param [Symbol, String] what Selector or id of an element
94
+ # @example Add region by element
95
+ # target.region(an_element)
96
+ # @example Add target region by finder
97
+ # target.region(:id, 'target_region')
98
+ # @return [Applitools::Selenium::Target] A Target instance.
99
+ # @!parse def region(element, how, what); end;
100
+ # rubocop:enable LineLength
101
+
92
102
  def region(*args)
93
103
  self.region_to_check = case args.first
94
- when Applitools::Selenium::Element
95
- proc { args.first }
96
- when Applitools::Region
104
+ when Applitools::Selenium::Element, Applitools::Region, ::Selenium::WebDriver::Element
97
105
  proc { args.first }
98
106
  else
99
107
  proc do |driver|
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.10.1'.freeze
2
+ VERSION = '3.10.2'.freeze
3
3
  end
data/lib/eyes_selenium.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require 'eyes_core'
2
2
 
3
3
  module Applitools
4
+ # @!visibility private
5
+ STITCH_MODE = {
6
+ :scroll => :SCROLL,
7
+ :css => :CSS
8
+ }.freeze
9
+
4
10
  module Selenium
5
11
  extend Applitools::RequireUtils
6
12
  def self.load_dir
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.10.1
4
+ version: 3.10.2
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-06-02 00:00:00.000000000 Z
11
+ date: 2017-07-10 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.10.1
19
+ version: 3.10.2
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.10.1
26
+ version: 3.10.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +92,6 @@ files:
92
92
  - lib/applitools/selenium/frame_chain.rb
93
93
  - lib/applitools/selenium/full_page_capture_algorithm.rb
94
94
  - lib/applitools/selenium/keyboard.rb
95
- - lib/applitools/selenium/match_window_task.rb
96
95
  - lib/applitools/selenium/mouse.rb
97
96
  - lib/applitools/selenium/move_to_region_visibility_strategy.rb
98
97
  - lib/applitools/selenium/nop_region_visibility_strategy.rb
@@ -123,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
122
  version: '0'
124
123
  requirements: []
125
124
  rubyforge_project:
126
- rubygems_version: 2.5.1
125
+ rubygems_version: 2.6.8
127
126
  signing_key:
128
127
  specification_version: 4
129
128
  summary: Applitools Ruby Images SDK
File without changes