watir 6.0.3 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGES.md +8 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/watir/after_hooks.rb +2 -2
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +1 -1
- data/lib/watir/element_collection.rb +2 -2
- data/lib/watir/elements/element.rb +4 -6
- data/lib/watir/elements/html_elements.rb +51 -51
- data/lib/watir/elements/image.rb +1 -1
- data/lib/watir/elements/select.rb +22 -79
- data/lib/watir/elements/svg_elements.rb +56 -56
- data/lib/watir/elements/table.rb +1 -1
- data/lib/watir/elements/table_section.rb +1 -1
- data/lib/watir/generator/base/visitor.rb +1 -1
- data/lib/watir/legacy_wait.rb +2 -2
- data/lib/watir/locators/element/locator.rb +8 -5
- data/lib/watir/locators/element/selector_builder.rb +2 -2
- data/lib/watir/wait.rb +18 -18
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/window.rb +4 -4
- data/lib/watirspec.rb +4 -7
- data/lib/watirspec/guards.rb +3 -1
- data/lib/watirspec/implementation.rb +8 -0
- data/spec/browser_spec.rb +4 -4
- data/spec/element_locator_spec.rb +4 -3
- data/spec/element_spec.rb +1 -1
- data/spec/watirspec/element_hidden_spec.rb +11 -1
- data/spec/watirspec/elements/select_list_spec.rb +4 -4
- data/spec/watirspec/html/wait.html +14 -0
- data/spec/watirspec/relaxed_locate_spec.rb +4 -0
- data/spec/watirspec/support/raise_exception_matchers.rb +2 -1
- data/spec/watirspec/wait_spec.rb +77 -1
- data/watir.gemspec +2 -2
- metadata +3 -3
@@ -5,7 +5,7 @@ module Watir
|
|
5
5
|
attribute(String, :style, :style)
|
6
6
|
attribute(String, :ownersvg_element, :ownerSVGElement)
|
7
7
|
attribute(String, :viewport_element, :viewportElement)
|
8
|
-
attribute(
|
8
|
+
attribute(Integer, :tab_index, :tabIndex)
|
9
9
|
end
|
10
10
|
class SVGElementCollection < ElementCollection
|
11
11
|
end
|
@@ -52,14 +52,14 @@ module Watir
|
|
52
52
|
attribute(String, :view_target, :viewTarget)
|
53
53
|
attribute(String, :view_box, :viewBox)
|
54
54
|
attribute(String, :preserve_aspect_ratio, :preserveAspectRatio)
|
55
|
-
attribute(
|
55
|
+
attribute(Integer, :zoom_and_pan, :zoomAndPan)
|
56
56
|
end
|
57
57
|
class ViewCollection < ElementCollection
|
58
58
|
end
|
59
59
|
|
60
60
|
class Cursor < SVGElement
|
61
|
-
attribute(
|
62
|
-
attribute(
|
61
|
+
attribute(Integer, :x, :x)
|
62
|
+
attribute(Integer, :y, :y)
|
63
63
|
attribute(String, :href, :href)
|
64
64
|
end
|
65
65
|
class CursorCollection < ElementCollection
|
@@ -69,10 +69,10 @@ module Watir
|
|
69
69
|
attribute(String, :pattern_units, :patternUnits)
|
70
70
|
attribute(String, :pattern_content_units, :patternContentUnits)
|
71
71
|
attribute(String, :pattern_transform, :patternTransform)
|
72
|
-
attribute(
|
73
|
-
attribute(
|
74
|
-
attribute(
|
75
|
-
attribute(
|
72
|
+
attribute(Integer, :x, :x)
|
73
|
+
attribute(Integer, :y, :y)
|
74
|
+
attribute(Integer, :width, :width)
|
75
|
+
attribute(Integer, :height, :height)
|
76
76
|
attribute(String, :view_box, :viewBox)
|
77
77
|
attribute(String, :preserve_aspect_ratio, :preserveAspectRatio)
|
78
78
|
attribute(String, :href, :href)
|
@@ -106,38 +106,38 @@ module Watir
|
|
106
106
|
end
|
107
107
|
|
108
108
|
class MeshGradient < Gradient
|
109
|
-
attribute(
|
110
|
-
attribute(
|
109
|
+
attribute(Integer, :x, :x)
|
110
|
+
attribute(Integer, :y, :y)
|
111
111
|
end
|
112
112
|
class MeshGradientCollection < ElementCollection
|
113
113
|
end
|
114
114
|
|
115
115
|
class RadialGradient < Gradient
|
116
|
-
attribute(
|
117
|
-
attribute(
|
118
|
-
attribute(
|
119
|
-
attribute(
|
120
|
-
attribute(
|
121
|
-
attribute(
|
116
|
+
attribute(Integer, :cx, :cx)
|
117
|
+
attribute(Integer, :cy, :cy)
|
118
|
+
attribute(Integer, :r, :r)
|
119
|
+
attribute(Integer, :fx, :fx)
|
120
|
+
attribute(Integer, :fy, :fy)
|
121
|
+
attribute(Integer, :fr, :fr)
|
122
122
|
end
|
123
123
|
class RadialGradientCollection < ElementCollection
|
124
124
|
end
|
125
125
|
|
126
126
|
class LinearGradient < Gradient
|
127
|
-
attribute(
|
128
|
-
attribute(
|
129
|
-
attribute(
|
130
|
-
attribute(
|
127
|
+
attribute(Integer, :x1, :x1)
|
128
|
+
attribute(Integer, :y1, :y1)
|
129
|
+
attribute(Integer, :x2, :x2)
|
130
|
+
attribute(Integer, :y2, :y2)
|
131
131
|
end
|
132
132
|
class LinearGradientCollection < ElementCollection
|
133
133
|
end
|
134
134
|
|
135
135
|
class Marker < SVGElement
|
136
|
-
attribute(
|
137
|
-
attribute(
|
136
|
+
attribute(Integer, :refx, :refX)
|
137
|
+
attribute(Integer, :refy, :refY)
|
138
138
|
attribute(String, :marker_units, :markerUnits)
|
139
|
-
attribute(
|
140
|
-
attribute(
|
139
|
+
attribute(Integer, :marker_width, :markerWidth)
|
140
|
+
attribute(Integer, :marker_height, :markerHeight)
|
141
141
|
attribute(String, :orient_type, :orientType)
|
142
142
|
attribute(String, :orient_angle, :orientAngle)
|
143
143
|
attribute(String, :orient, :orient)
|
@@ -174,23 +174,23 @@ module Watir
|
|
174
174
|
end
|
175
175
|
|
176
176
|
class ForeignObject < Graphics
|
177
|
-
attribute(
|
178
|
-
attribute(
|
179
|
-
attribute(
|
180
|
-
attribute(
|
177
|
+
attribute(Integer, :x, :x)
|
178
|
+
attribute(Integer, :y, :y)
|
179
|
+
attribute(Integer, :width, :width)
|
180
|
+
attribute(Integer, :height, :height)
|
181
181
|
end
|
182
182
|
class ForeignObjectCollection < ElementCollection
|
183
183
|
end
|
184
184
|
|
185
185
|
class TextContent < Graphics
|
186
|
-
attribute(
|
186
|
+
attribute(Integer, :text_length, :textLength)
|
187
187
|
attribute(String, :length_adjust, :lengthAdjust)
|
188
188
|
end
|
189
189
|
class TextContentCollection < ElementCollection
|
190
190
|
end
|
191
191
|
|
192
192
|
class TextPath < TextContent
|
193
|
-
attribute(
|
193
|
+
attribute(Integer, :start_offset, :startOffset)
|
194
194
|
attribute(String, :method, :method)
|
195
195
|
attribute(String, :spacing, :spacing)
|
196
196
|
attribute(String, :href, :href)
|
@@ -221,10 +221,10 @@ module Watir
|
|
221
221
|
end
|
222
222
|
|
223
223
|
class Use < Graphics
|
224
|
-
attribute(
|
225
|
-
attribute(
|
226
|
-
attribute(
|
227
|
-
attribute(
|
224
|
+
attribute(Integer, :x, :x)
|
225
|
+
attribute(Integer, :y, :y)
|
226
|
+
attribute(Integer, :width, :width)
|
227
|
+
attribute(Integer, :height, :height)
|
228
228
|
attribute(String, :href, :href)
|
229
229
|
end
|
230
230
|
class UseCollection < ElementCollection
|
@@ -241,10 +241,10 @@ module Watir
|
|
241
241
|
end
|
242
242
|
|
243
243
|
class SVG < Graphics
|
244
|
-
attribute(
|
245
|
-
attribute(
|
246
|
-
attribute(
|
247
|
-
attribute(
|
244
|
+
attribute(Integer, :x, :x)
|
245
|
+
attribute(Integer, :y, :y)
|
246
|
+
attribute(Integer, :width, :width)
|
247
|
+
attribute(Integer, :height, :height)
|
248
248
|
attribute(String, :viewport, :viewport)
|
249
249
|
attribute("Boolean", :use_current_view?, :useCurrentView)
|
250
250
|
attribute(String, :current_view, :currentView)
|
@@ -252,7 +252,7 @@ module Watir
|
|
252
252
|
attribute(String, :current_translate, :currentTranslate)
|
253
253
|
attribute(String, :view_box, :viewBox)
|
254
254
|
attribute(String, :preserve_aspect_ratio, :preserveAspectRatio)
|
255
|
-
attribute(
|
255
|
+
attribute(Integer, :zoom_and_pan, :zoomAndPan)
|
256
256
|
end
|
257
257
|
class SVGCollection < ElementCollection
|
258
258
|
end
|
@@ -277,38 +277,38 @@ module Watir
|
|
277
277
|
end
|
278
278
|
|
279
279
|
class Line < Geometry
|
280
|
-
attribute(
|
281
|
-
attribute(
|
282
|
-
attribute(
|
283
|
-
attribute(
|
280
|
+
attribute(Integer, :x1, :x1)
|
281
|
+
attribute(Integer, :y1, :y1)
|
282
|
+
attribute(Integer, :x2, :x2)
|
283
|
+
attribute(Integer, :y2, :y2)
|
284
284
|
end
|
285
285
|
class LineCollection < ElementCollection
|
286
286
|
end
|
287
287
|
|
288
288
|
class Ellipse < Geometry
|
289
|
-
attribute(
|
290
|
-
attribute(
|
291
|
-
attribute(
|
292
|
-
attribute(
|
289
|
+
attribute(Integer, :cx, :cx)
|
290
|
+
attribute(Integer, :cy, :cy)
|
291
|
+
attribute(Integer, :rx, :rx)
|
292
|
+
attribute(Integer, :ry, :ry)
|
293
293
|
end
|
294
294
|
class EllipseCollection < ElementCollection
|
295
295
|
end
|
296
296
|
|
297
297
|
class Circle < Geometry
|
298
|
-
attribute(
|
299
|
-
attribute(
|
300
|
-
attribute(
|
298
|
+
attribute(Integer, :cx, :cx)
|
299
|
+
attribute(Integer, :cy, :cy)
|
300
|
+
attribute(Integer, :r, :r)
|
301
301
|
end
|
302
302
|
class CircleCollection < ElementCollection
|
303
303
|
end
|
304
304
|
|
305
305
|
class Rect < Geometry
|
306
|
-
attribute(
|
307
|
-
attribute(
|
308
|
-
attribute(
|
309
|
-
attribute(
|
310
|
-
attribute(
|
311
|
-
attribute(
|
306
|
+
attribute(Integer, :x, :x)
|
307
|
+
attribute(Integer, :y, :y)
|
308
|
+
attribute(Integer, :width, :width)
|
309
|
+
attribute(Integer, :height, :height)
|
310
|
+
attribute(Integer, :rx, :rx)
|
311
|
+
attribute(Integer, :ry, :ry)
|
312
312
|
end
|
313
313
|
class RectCollection < ElementCollection
|
314
314
|
end
|
data/lib/watir/elements/table.rb
CHANGED
data/lib/watir/legacy_wait.rb
CHANGED
@@ -74,7 +74,7 @@ module Watir
|
|
74
74
|
# browser.text_field(name: "new_user_first_name").when_present { |field| field.set "Watir" }
|
75
75
|
# browser.text_field(name: "new_user_first_name").when_present(60).text
|
76
76
|
#
|
77
|
-
# @param [
|
77
|
+
# @param [Integer] timeout seconds to wait before timing out
|
78
78
|
#
|
79
79
|
# @see Watir::Wait
|
80
80
|
# @see Watir::Element#present?
|
@@ -102,7 +102,7 @@ module Watir
|
|
102
102
|
# @example
|
103
103
|
# browser.button(name: "new_user_button_2").when_enabled.click
|
104
104
|
#
|
105
|
-
# @param [
|
105
|
+
# @param [Integer] timeout seconds to wait before timing out
|
106
106
|
#
|
107
107
|
# @see Watir::Wait
|
108
108
|
# @see Watir::Element#enabled?
|
@@ -132,17 +132,20 @@ module Watir
|
|
132
132
|
|
133
133
|
def find_all_by_multiple
|
134
134
|
selector = selector_builder.normalized_selector
|
135
|
+
visible = selector.delete(:visible)
|
135
136
|
|
136
137
|
if selector.key? :index
|
137
138
|
raise ArgumentError, "can't locate all elements by :index"
|
138
139
|
end
|
139
140
|
|
140
141
|
how, what = selector_builder.build(selector)
|
141
|
-
if how
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
found = if how
|
143
|
+
@query_scope.wd.find_elements(how, what)
|
144
|
+
else
|
145
|
+
wd_find_by_regexp_selector(selector, :select)
|
146
|
+
end
|
147
|
+
found.select! { |el| el.displayed? == visible } unless visible.nil?
|
148
|
+
found
|
146
149
|
end
|
147
150
|
|
148
151
|
def wd_find_all_by(how, what)
|
@@ -27,8 +27,8 @@ module Watir
|
|
27
27
|
def check_type(how, what)
|
28
28
|
case how
|
29
29
|
when :index
|
30
|
-
unless what.is_a?(
|
31
|
-
raise TypeError, "expected
|
30
|
+
unless what.is_a?(Integer)
|
31
|
+
raise TypeError, "expected Integer, got #{what.inspect}:#{what.class}"
|
32
32
|
end
|
33
33
|
when :visible
|
34
34
|
unless what.is_a?(TrueClass) || what.is_a?(FalseClass)
|
data/lib/watir/wait.rb
CHANGED
@@ -29,20 +29,20 @@ module Watir
|
|
29
29
|
# @example
|
30
30
|
# Watir::Wait.until { browser.text_field(name: "new_user_first_name").visible? }
|
31
31
|
#
|
32
|
-
# @param [
|
32
|
+
# @param [Integer] timeout How long to wait in seconds
|
33
33
|
# @param [String] message Message to raise if timeout is exceeded
|
34
34
|
# @param [Object, NilClass] object Object to evaluate block against
|
35
35
|
# @raise [TimeoutError] if timeout is exceeded
|
36
36
|
#
|
37
37
|
|
38
|
-
def until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, object: nil)
|
38
|
+
def until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, object: nil)
|
39
39
|
if deprecated_message || deprecated_timeout
|
40
40
|
warn "Instead of passing arguments into Wait#until method, use keywords"
|
41
41
|
timeout = deprecated_timeout
|
42
42
|
message = deprecated_message
|
43
43
|
end
|
44
44
|
timeout ||= Watir.default_timeout
|
45
|
-
run_with_timer(timeout) do
|
45
|
+
run_with_timer(timeout, interval) do
|
46
46
|
result = yield(object)
|
47
47
|
return result if result
|
48
48
|
end
|
@@ -55,20 +55,20 @@ module Watir
|
|
55
55
|
# @example
|
56
56
|
# Watir::Wait.while { browser.text_field(name: "abrakadbra").present? }
|
57
57
|
#
|
58
|
-
# @param [
|
58
|
+
# @param [Integer] timeout How long to wait in seconds
|
59
59
|
# @param [String] message Message to raise if timeout is exceeded
|
60
60
|
# @param [Object, NilClass] object Object to evaluate block against
|
61
61
|
# @raise [TimeoutError] if timeout is exceeded
|
62
62
|
#
|
63
63
|
|
64
|
-
def while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, object: nil)
|
64
|
+
def while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, object: nil)
|
65
65
|
if deprecated_message || deprecated_timeout
|
66
66
|
warn "Instead of passing arguments into Wait#while method, use keywords"
|
67
67
|
timeout = deprecated_timeout
|
68
68
|
message = deprecated_message
|
69
69
|
end
|
70
70
|
timeout ||= Watir.default_timeout
|
71
|
-
run_with_timer(timeout) { return unless yield(object) }
|
71
|
+
run_with_timer(timeout, interval) { return unless yield(object) }
|
72
72
|
raise TimeoutError, message_for(timeout, message)
|
73
73
|
end
|
74
74
|
|
@@ -81,13 +81,13 @@ module Watir
|
|
81
81
|
err
|
82
82
|
end
|
83
83
|
|
84
|
-
def run_with_timer(timeout, &block)
|
84
|
+
def run_with_timer(timeout, interval, &block)
|
85
85
|
if timeout.zero?
|
86
86
|
block.call
|
87
87
|
else
|
88
88
|
timer.wait(timeout) do
|
89
89
|
block.call
|
90
|
-
sleep INTERVAL
|
90
|
+
sleep interval || INTERVAL
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -111,18 +111,18 @@ module Watir
|
|
111
111
|
# browser.text_field(name: "new_user_first_name").wait_until(message: 'foo') { |field| field.present? }
|
112
112
|
# browser.text_field(name: "new_user_first_name").wait_until(timeout: 60, &:present?)
|
113
113
|
#
|
114
|
-
# @param [
|
114
|
+
# @param [Integer] timeout seconds to wait before timing out
|
115
115
|
# @param [String] message error message for when times out
|
116
116
|
#
|
117
117
|
|
118
|
-
def wait_until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, &blk)
|
118
|
+
def wait_until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, &blk)
|
119
119
|
if deprecated_message || deprecated_timeout
|
120
120
|
warn "Instead of passing arguments into #wait_until, use keywords"
|
121
121
|
timeout = deprecated_timeout
|
122
122
|
message = deprecated_message
|
123
123
|
end
|
124
124
|
message ||= "waiting for true condition on #{selector_string}"
|
125
|
-
Wait.until(timeout: timeout, message: message, object: self, &blk)
|
125
|
+
Wait.until(timeout: timeout, message: message, interval: interval, object: self, &blk)
|
126
126
|
|
127
127
|
self
|
128
128
|
end
|
@@ -137,18 +137,18 @@ module Watir
|
|
137
137
|
#
|
138
138
|
# @todo add element example
|
139
139
|
#
|
140
|
-
# @param [
|
140
|
+
# @param [Integer] timeout seconds to wait before timing out
|
141
141
|
# @param [String] message error message for when times out
|
142
142
|
#
|
143
143
|
|
144
|
-
def wait_while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, &blk)
|
144
|
+
def wait_while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, &blk)
|
145
145
|
if deprecated_message || deprecated_timeout
|
146
146
|
warn "Instead of passing arguments into #wait_while method, use keywords"
|
147
147
|
timeout = deprecated_timeout
|
148
148
|
message = deprecated_message
|
149
149
|
end
|
150
150
|
message ||= "waiting for false condition on #{selector_string}"
|
151
|
-
Wait.while(timeout: timeout, message: message, object: self, &blk)
|
151
|
+
Wait.while(timeout: timeout, message: message, interval: interval, object: self, &blk)
|
152
152
|
|
153
153
|
self
|
154
154
|
end
|
@@ -159,18 +159,18 @@ module Watir
|
|
159
159
|
# @example
|
160
160
|
# browser.text_field(name: "new_user_first_name").wait_until_present
|
161
161
|
#
|
162
|
-
# @param [
|
162
|
+
# @param [Integer] timeout seconds to wait before timing out
|
163
163
|
#
|
164
164
|
# @see Watir::Wait
|
165
165
|
# @see Watir::Element#present?
|
166
166
|
#
|
167
167
|
|
168
|
-
def wait_until_present(deprecated_timeout = nil, timeout: nil)
|
168
|
+
def wait_until_present(deprecated_timeout = nil, timeout: nil, interval: nil)
|
169
169
|
if deprecated_timeout
|
170
170
|
warn "Instead of passing arguments into #wait_until_present method, use keywords"
|
171
171
|
timeout = deprecated_timeout
|
172
172
|
end
|
173
|
-
wait_until(timeout: timeout, &:present?)
|
173
|
+
wait_until(timeout: timeout, interval: interval, &:present?)
|
174
174
|
end
|
175
175
|
|
176
176
|
#
|
@@ -179,7 +179,7 @@ module Watir
|
|
179
179
|
# @example
|
180
180
|
# browser.text_field(name: "abrakadbra").wait_while_present
|
181
181
|
#
|
182
|
-
# @param [
|
182
|
+
# @param [Integer] timeout seconds to wait before timing out
|
183
183
|
#
|
184
184
|
# @see Watir::Wait
|
185
185
|
# @see Watir::Element#present?
|