eyes_selenium 1.17.0 → 1.18.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTI2OWYyOThlNTk4ZTRkYWFlZjIxZDlmNGUwMzU5MjRkZTA5M2M2Mg==
5
+ data.tar.gz: !binary |-
6
+ Nzc3MGM5NmVjZGNiODk4OWVhMzUxNTY5NzY4ZDRmZDg4MGYxMDE3Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTkxYmY2NmVlMWI3NDZlNmYzYWFiYWRlMWU5YjU1YjU2ZDI1YjAyMTcwN2Nm
10
+ ZmQwMDYzNjgzYjM5ODg3ZWY2ZmRjNGMyYzZlMmRjMjFhOGI3ZWNlM2IwN2Y4
11
+ NWExMzMzMGY1YTk1NmY5MGJhNjAwMTIwMzlkZmIwOWFjMmE1OTM=
12
+ data.tar.gz: !binary |-
13
+ NTdjMTE4MDVlY2VjZTQyYzJmNDdlMTkwYTViZmEyNzk3YmU0ZGI0YzA4MDli
14
+ YjBjZjg5Zjg1ZTM4NWRlYTU0ZmQyNzYxZDhkYzFhNjE0MWViMDg2Mzg5NDMz
15
+ ZTMzYzcxMjMzNTZiOGRhY2I5YTA4ZDQzMDFlMGZkNDk4MjJlYmU=
@@ -4,8 +4,8 @@ class Applitools::Driver
4
4
 
5
5
  include Selenium::WebDriver::DriverExtensions::HasInputDevices
6
6
 
7
- attr_reader :remote_server_url, :remote_session_id, :user_agent, :screenshot_taker
8
- attr_accessor :user_inputs, :driver
7
+ attr_reader :remote_server_url, :remote_session_id, :user_agent, :screenshot_taker, :eyes
8
+ attr_accessor :driver
9
9
 
10
10
  DRIVER_METHODS = [
11
11
  :title, :execute_script, :execute_async_script, :quit, :close, :get,
@@ -15,10 +15,9 @@ class Applitools::Driver
15
15
 
16
16
  ## If driver is not provided, Applitools::Driver will raise an EyesError exception.
17
17
  #
18
- def initialize(options)
18
+ def initialize(eyes, options)
19
19
  @driver = options[:driver]
20
-
21
- @user_inputs = []
20
+ @eyes = eyes
22
21
  @remote_server_url = address_of_remote_server
23
22
  @remote_session_id = remote_session_id
24
23
  @user_agent = get_user_agent
@@ -68,10 +67,6 @@ class Applitools::Driver
68
67
  Applitools::TargetApp.new(remote_server_url, remote_session_id, user_agent)
69
68
  end
70
69
 
71
- def clear_user_inputs
72
- user_inputs.clear
73
- end
74
-
75
70
  def ie?
76
71
  driver.to_s == 'ie'
77
72
  end
@@ -28,7 +28,7 @@ class Applitools::Element
28
28
  def click
29
29
  current_control = region
30
30
  offset = current_control.middle_offset
31
- driver.user_inputs << Applitools::MouseTrigger.new(:click, current_control, offset)
31
+ driver.eyes.user_inputs << Applitools::MouseTrigger.new(:click, current_control, offset)
32
32
 
33
33
  web_element.click
34
34
  end
@@ -45,7 +45,7 @@ class Applitools::Element
45
45
  def send_keys(*args)
46
46
  current_control = region
47
47
  Selenium::WebDriver::Keys.encode(args).each do |key|
48
- driver.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control)
48
+ driver.eyes.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control)
49
49
  end
50
50
 
51
51
  web_element.send_keys(args)
@@ -19,7 +19,7 @@ class Applitools::Eyes
19
19
  attr_reader :agent_connector, :disabled
20
20
  attr_accessor :app_name, :test_name, :session, :is_open, :aborted, :viewport_size, :match_timeout,
21
21
  :failure_reports, :test_batch, :match_level, :driver, :host_os, :host_app, :branch_name, :parent_branch_name,
22
- :should_match_window_run_once_on_timeout, :session_start_info, :match_window_task
22
+ :should_match_window_run_once_on_timeout, :session_start_info, :match_window_task, :user_inputs
23
23
 
24
24
  def config
25
25
  self.class.config
@@ -32,6 +32,7 @@ class Applitools::Eyes
32
32
 
33
33
  return if disabled?
34
34
 
35
+ @user_inputs = []
35
36
  @agent_connector = Applitools::AgentConnector.new(config[:server_url], config[:user], config[:apikey])
36
37
  @match_timeout = DEFAULT_MATCH_TIMEOUT
37
38
  @failure_reports = Applitools::FailureReports::ON_CLOSE
@@ -45,7 +46,7 @@ class Applitools::Eyes
45
46
  raise Applitools::EyesError.new("driver/browser must be a valid Selenium webdriver")
46
47
  end
47
48
 
48
- @driver = Applitools::Driver.new(driver: @driver)
49
+ @driver = Applitools::Driver.new(self, {driver: @driver})
49
50
 
50
51
  if open?
51
52
  abort_if_not_closed
@@ -67,6 +68,10 @@ class Applitools::Eyes
67
68
  self.is_open
68
69
  end
69
70
 
71
+ def clear_user_inputs
72
+ user_inputs.clear
73
+ end
74
+
70
75
  def check_window(tag)
71
76
  return if disabled?
72
77
  raise Applitools::EyesError.new("Eyes not open") if !open?
@@ -10,7 +10,7 @@ class Applitools::EyesKeyboard
10
10
  active_element = Applitools::Element.new(driver, driver.switch_to.active_element)
11
11
  current_control = active_element.region
12
12
  Selenium::WebDriver::Keys.encode(keys).each do |key|
13
- driver.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control)
13
+ driver.eyes.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control)
14
14
  end
15
15
  keyboard.send_keys(*keys)
16
16
  end
@@ -32,7 +32,7 @@ class Applitools::EyesMouse
32
32
  location.x = [0,location.x].max.round
33
33
  location.y = [0,location.y].max.round
34
34
  current_control = Applitools::Region.new(0,0, *location.values)
35
- driver.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
35
+ driver.eyes.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
36
36
  element = element.web_element if element.is_a?(Applitools::Element)
37
37
  mouse.move_to(element,right_by, down_by)
38
38
  end
@@ -42,7 +42,7 @@ class Applitools::EyesMouse
42
42
  down = [0,down_by].max.round
43
43
  location = Selenium::WebDriver::Point.new(right,down)
44
44
  current_control = Applitools::Region.new(0,0, right, down)
45
- driver.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
45
+ driver.eyes.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
46
46
  mouse.move_by(right_by,down_by)
47
47
  end
48
48
 
@@ -53,7 +53,7 @@ class Applitools::EyesMouse
53
53
  location.x = [0,location.x].max.round
54
54
  location.y = [0,location.y].max.round
55
55
  current_control = Applitools::Region.new(0,0, *location.values)
56
- driver.user_inputs << Applitools::MouseTrigger.new(method, current_control, location)
56
+ driver.eyes.user_inputs << Applitools::MouseTrigger.new(method, current_control, location)
57
57
  element = element.web_element if element.is_a?(Applitools::Element)
58
58
  mouse.send(method,element,*args)
59
59
  end
@@ -26,7 +26,7 @@ class Applitools::MatchWindowTask
26
26
  run_with_intervals(tag, max_window_load_time)
27
27
  end
28
28
 
29
- driver.clear_user_inputs and return res
29
+ driver.eyes.clear_user_inputs and return res
30
30
  end
31
31
 
32
32
  def run(tag, wait_before_run=nil)
@@ -55,8 +55,33 @@ class Applitools::MatchWindowTask
55
55
  current_screenshot_encoded,
56
56
  @last_checked_window)
57
57
  app_output = AppOutput.new(title, nil)
58
-
59
- return Applitools::MatchWindowData.new(app_output, driver.user_inputs, tag, ignore_mismatch, compressed_screenshot)
58
+ user_inputs = []
59
+ if @last_checked_window.nil?
60
+ user_inputs = driver.eyes.user_inputs
61
+ else
62
+ driver.eyes.user_inputs.each do |trigger|
63
+ if trigger.is_a? Applitools::MouseTrigger
64
+ trigger_left = trigger.control.left + trigger.location.x
65
+ trigger_top = trigger.control.top + trigger.location.y
66
+ if trigger_left <= @last_checked_window.width && trigger_top <= @last_checked_window.height
67
+ user_inputs << trigger
68
+ else
69
+ EyesLogger.info "Trigger ignored: #{trigger} (out of bounds)"
70
+ end
71
+ elsif trigger.is_a? Applitools::TextTrigger
72
+ last_screenshot_bounds = Applitools::Region.new(0, 0, @last_checked_window.width, @last_checked_window.height)
73
+ if trigger.control.intersecting?last_screenshot_bounds
74
+ user_inputs << trigger
75
+ else
76
+ EyesLogger.info "Trigger ignored: #{trigger} (out of bounds)"
77
+ end
78
+ else
79
+ EyesLogger.info "Trigger ignored: #{trigger} (Unrecognized trigger)"
80
+ end
81
+ end
82
+ end
83
+
84
+ Applitools::MatchWindowData.new(app_output, user_inputs, tag, ignore_mismatch, compressed_screenshot)
60
85
  end
61
86
 
62
87
  def match(tag, ignore_mismatch=false)
@@ -16,4 +16,8 @@ class Applitools::MouseTrigger
16
16
  control: control.to_hash, location: Hash[location.each_pair.to_a]
17
17
  }
18
18
  end
19
+
20
+ def to_s
21
+ "#{mouse_action} [#{control}] #{location.x}, #{location.y}"
22
+ end
19
23
  end
@@ -8,6 +8,47 @@ class Applitools::Region
8
8
  @height = height.round
9
9
  end
10
10
 
11
+ EMPTY = Applitools::Region.new(0, 0, 0, 0)
12
+
13
+ def make_empty
14
+ @left = EMPTY.left
15
+ @top = EMPTY.top
16
+ @width = EMPTY.width
17
+ @height = EMPTY.height
18
+ end
19
+
20
+ def empty?
21
+ self.left == EMPTY.left && self.top == EMPTY.top && self.width == EMPTY.width && self.height == EMPTY.height
22
+ end
23
+
24
+ def right
25
+ left + width
26
+ end
27
+
28
+ def bottom
29
+ top + height
30
+ end
31
+
32
+ def intersecting?(other)
33
+ ((left <= other.left && other.left <= right) || (other.left <= left && left <= other.right)) \
34
+ && ((top <= other.top && other.top <= bottom) || (other.top <= top && top <=other.bottom))
35
+ end
36
+
37
+ def intersect(other)
38
+ if !intersecting?(other)
39
+ make_empty and return
40
+ end
41
+ i_left = (left >= other.left) ? left : other.left
42
+ i_right = (right <= other.right) ? right : other.right
43
+ i_top = (top >= other.top) ? top : other.top
44
+ i_bottom = (bottom <= other.bottom) ? bottom : other.bottom
45
+
46
+ self.left = i_left
47
+ self.top = i_top
48
+ self.width = i_right - i_left
49
+ self.height = i_bottom - i_top
50
+ end
51
+
11
52
  def middle_offset
12
53
  mid_x = width / 2
13
54
  mid_y = height / 2
@@ -19,4 +60,8 @@ class Applitools::Region
19
60
  "$type" => "Applitools.Utils.Geometry.MutableRegion, Core", left: left, top: top, height: height, width: width
20
61
  }
21
62
  end
63
+
64
+ def to_s
65
+ "(#{left}, #{top}), #{width} x #{height}"
66
+ end
22
67
  end
@@ -12,4 +12,8 @@ class Applitools::TextTrigger
12
12
  "$type" => "Applitools.Models.TextTrigger, Core", text: text, control: control.to_hash
13
13
  }
14
14
  end
15
+
16
+ def to_s
17
+ "Text [#{@control}] #{@text}"
18
+ end
15
19
  end
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = "1.17.0"
2
+ VERSION = "1.18.0"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
5
- prerelease:
4
+ version: 1.18.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Applitools team
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: selenium-webdriver
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: httparty
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: oily_png
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: capybara
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: sinatra
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - ! '>='
140
123
  - !ruby/object:Gem::Version
@@ -186,32 +169,25 @@ files:
186
169
  homepage: http://www.applitools.com
187
170
  licenses:
188
171
  - Apache License, Version 2.0
172
+ metadata: {}
189
173
  post_install_message:
190
174
  rdoc_options: []
191
175
  require_paths:
192
176
  - lib
193
177
  required_ruby_version: !ruby/object:Gem::Requirement
194
- none: false
195
178
  requirements:
196
179
  - - ! '>='
197
180
  - !ruby/object:Gem::Version
198
181
  version: '0'
199
- segments:
200
- - 0
201
- hash: -3490962404448018884
202
182
  required_rubygems_version: !ruby/object:Gem::Requirement
203
- none: false
204
183
  requirements:
205
184
  - - ! '>='
206
185
  - !ruby/object:Gem::Version
207
186
  version: '0'
208
- segments:
209
- - 0
210
- hash: -3490962404448018884
211
187
  requirements: []
212
188
  rubyforge_project:
213
- rubygems_version: 1.8.25
189
+ rubygems_version: 2.1.11
214
190
  signing_key:
215
- specification_version: 3
191
+ specification_version: 4
216
192
  summary: Applitools Ruby SDK
217
193
  test_files: []