watir 6.19.1 → 7.0.0.beta1
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 +4 -4
- data/.github/actions/install-chrome/action.yml +1 -0
- data/.github/actions/setup-linux/action.yml +8 -0
- data/.github/workflows/tests.yml +100 -0
- data/CHANGES.md +7 -0
- data/README.md +1 -4
- data/Rakefile +1 -1
- data/lib/watir.rb +1 -45
- data/lib/watir/alert.rb +3 -8
- data/lib/watir/capabilities.rb +54 -230
- data/lib/watir/cell_container.rb +4 -4
- data/lib/watir/container.rb +4 -26
- data/lib/watir/elements/checkbox.rb +4 -4
- data/lib/watir/elements/date_field.rb +4 -4
- data/lib/watir/elements/date_time_field.rb +4 -4
- data/lib/watir/elements/element.rb +12 -49
- data/lib/watir/elements/file_field.rb +4 -4
- data/lib/watir/elements/font.rb +4 -4
- data/lib/watir/elements/hidden.rb +4 -4
- data/lib/watir/elements/html_elements.rb +444 -445
- data/lib/watir/elements/iframe.rb +4 -4
- data/lib/watir/elements/radio.rb +4 -4
- data/lib/watir/elements/select.rb +12 -78
- data/lib/watir/elements/svg_elements.rb +96 -96
- data/lib/watir/elements/text_field.rb +4 -4
- data/lib/watir/generator/base/generator.rb +4 -4
- data/lib/watir/generator/base/visitor.rb +0 -29
- data/lib/watir/generator/html/generator.rb +2 -1
- data/lib/watir/has_window.rb +4 -4
- data/lib/watir/http_client.rb +0 -8
- data/lib/watir/locators.rb +1 -5
- data/lib/watir/locators/button/matcher.rb +0 -23
- data/lib/watir/locators/button/selector_builder/xpath.rb +4 -15
- data/lib/watir/locators/element/matcher.rb +4 -19
- data/lib/watir/locators/element/selector_builder.rb +2 -37
- data/lib/watir/locators/element/selector_builder/xpath.rb +26 -41
- data/lib/watir/radio_set.rb +2 -2
- data/lib/watir/row_container.rb +4 -4
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +4 -74
- data/lib/watir/window.rb +6 -22
- data/lib/watir/window_collection.rb +5 -49
- data/lib/watirspec/implementation.rb +4 -0
- data/spec/spec_helper.rb +2 -7
- data/spec/unit/capabilities_spec.rb +196 -929
- data/spec/unit/match_elements/button_spec.rb +0 -13
- data/spec/unit/match_elements/element_spec.rb +38 -47
- data/spec/unit/match_elements/text_field_spec.rb +6 -6
- data/spec/unit/selector_builder/element_spec.rb +6 -23
- data/spec/unit/selector_builder/text_field_spec.rb +6 -7
- data/spec/watirspec/alert_spec.rb +4 -21
- data/spec/watirspec/browser_spec.rb +2 -2
- data/spec/watirspec/cookies_spec.rb +1 -1
- data/spec/watirspec/elements/button_spec.rb +0 -10
- data/spec/watirspec/elements/checkbox_spec.rb +10 -22
- data/spec/watirspec/elements/div_spec.rb +4 -34
- data/spec/watirspec/elements/divs_spec.rb +2 -2
- data/spec/watirspec/elements/element_spec.rb +38 -84
- data/spec/watirspec/elements/form_spec.rb +2 -4
- data/spec/watirspec/elements/links_spec.rb +4 -4
- data/spec/watirspec/elements/select_list_spec.rb +7 -108
- data/spec/watirspec/elements/span_spec.rb +2 -2
- data/spec/watirspec/elements/spans_spec.rb +1 -1
- data/spec/watirspec/elements/strong_spec.rb +1 -1
- data/spec/watirspec/html/non_control_elements.html +8 -3
- data/spec/watirspec/support/rspec_matchers.rb +1 -32
- data/spec/watirspec/window_switching_spec.rb +2 -49
- data/spec/watirspec_helper.rb +6 -1
- data/watir.gemspec +3 -4
- metadata +11 -32
- data/.github/workflows/linux.yml +0 -61
- data/.github/workflows/mac.yml +0 -55
- data/.github/workflows/unit.yml +0 -37
- data/.github/workflows/windows.yml +0 -39
- data/lib/watir/legacy_wait.rb +0 -123
- data/spec/unit/container_spec.rb +0 -35
- data/spec/watirspec/legacy_wait_spec.rb +0 -216
data/lib/watir/version.rb
CHANGED
data/lib/watir/wait.rb
CHANGED
|
@@ -32,12 +32,7 @@ module Watir
|
|
|
32
32
|
# @raise [TimeoutError] if timeout is exceeded
|
|
33
33
|
#
|
|
34
34
|
|
|
35
|
-
def until(
|
|
36
|
-
if depr_message || depr_timeout
|
|
37
|
-
Watir.logger.deprecate 'Using arguments for Wait#until', 'keywords', ids: %i[until timeout_arguments]
|
|
38
|
-
timeout = depr_timeout
|
|
39
|
-
message = depr_message
|
|
40
|
-
end
|
|
35
|
+
def until(timeout: nil, message: nil, interval: nil, object: nil)
|
|
41
36
|
timeout ||= Watir.default_timeout
|
|
42
37
|
run_with_timer(timeout, interval) do
|
|
43
38
|
result = yield(object)
|
|
@@ -58,12 +53,7 @@ module Watir
|
|
|
58
53
|
# @raise [TimeoutError] if timeout is exceeded
|
|
59
54
|
#
|
|
60
55
|
|
|
61
|
-
def while(
|
|
62
|
-
if depr_message || depr_timeout
|
|
63
|
-
Watir.logger.deprecate 'Using arguments for Wait#while', 'keywords', ids: %i[while timeout_arguments]
|
|
64
|
-
timeout = depr_timeout
|
|
65
|
-
message = depr_message
|
|
66
|
-
end
|
|
56
|
+
def while(timeout: nil, message: nil, interval: nil, object: nil)
|
|
67
57
|
timeout ||= Watir.default_timeout
|
|
68
58
|
run_with_timer(timeout, interval) { return unless yield(object) }
|
|
69
59
|
raise TimeoutError, message_for(timeout, object, message)
|
|
@@ -111,12 +101,7 @@ module Watir
|
|
|
111
101
|
# @param [String] message error message for when times out
|
|
112
102
|
#
|
|
113
103
|
|
|
114
|
-
def wait_until(
|
|
115
|
-
if depr_message || depr_timeout
|
|
116
|
-
Watir.logger.deprecate 'Using arguments for #wait_until', 'keywords', ids: [:timeout_arguments]
|
|
117
|
-
timeout = depr_timeout
|
|
118
|
-
message = depr_message
|
|
119
|
-
end
|
|
104
|
+
def wait_until(timeout: nil, message: nil, interval: nil, **opt, &blk)
|
|
120
105
|
message ||= proc { |obj| "waiting for true condition on #{obj.inspect}" }
|
|
121
106
|
|
|
122
107
|
# TODO: Consider throwing argument error for mixing block & options
|
|
@@ -142,12 +127,7 @@ module Watir
|
|
|
142
127
|
# @param [String] message error message for when times out
|
|
143
128
|
#
|
|
144
129
|
|
|
145
|
-
def wait_while(
|
|
146
|
-
if depr_message || depr_timeout
|
|
147
|
-
Watir.logger.deprecate 'Using arguments for #wait_while', 'keywords', ids: [:timeout_arguments]
|
|
148
|
-
timeout = depr_timeout
|
|
149
|
-
message = depr_message
|
|
150
|
-
end
|
|
130
|
+
def wait_while(timeout: nil, message: nil, interval: nil, **opt, &blk)
|
|
151
131
|
message ||= proc { |obj| "waiting for false condition on #{obj.inspect}" }
|
|
152
132
|
|
|
153
133
|
# TODO: Consider throwing argument error for mixing block & options
|
|
@@ -158,56 +138,6 @@ module Watir
|
|
|
158
138
|
self
|
|
159
139
|
end
|
|
160
140
|
|
|
161
|
-
#
|
|
162
|
-
# Waits until the element is present.
|
|
163
|
-
# Element is always relocated, so this can be used in the case of an element going away and returning
|
|
164
|
-
#
|
|
165
|
-
# @example
|
|
166
|
-
# browser.text_field(name: "new_user_first_name").wait_until_present
|
|
167
|
-
#
|
|
168
|
-
# @param [Integer] timeout seconds to wait before timing out
|
|
169
|
-
# @param [Float] interval seconds to wait before each try
|
|
170
|
-
# @param [String] message error message for when times out
|
|
171
|
-
#
|
|
172
|
-
# @see Watir::Wait
|
|
173
|
-
# @see Watir::Element#present?
|
|
174
|
-
#
|
|
175
|
-
|
|
176
|
-
def wait_until_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
|
|
177
|
-
timeout = depr_timeout if depr_timeout
|
|
178
|
-
Watir.logger.deprecate "#{self.class}#wait_until_present",
|
|
179
|
-
"#{self.class}#wait_until(&:present?)",
|
|
180
|
-
ids: [:wait_until_present]
|
|
181
|
-
|
|
182
|
-
message ||= proc { |obj| "waiting for #{obj.inspect} to become present" }
|
|
183
|
-
wait_until(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
#
|
|
187
|
-
# Waits while the element is present.
|
|
188
|
-
# Element is always relocated, so this can be used in the case of the element changing attributes
|
|
189
|
-
#
|
|
190
|
-
# @example
|
|
191
|
-
# browser.text_field(name: "abrakadbra").wait_while_present
|
|
192
|
-
#
|
|
193
|
-
# @param [Integer] timeout seconds to wait before timing out
|
|
194
|
-
# @param [Float] interval seconds to wait before each try
|
|
195
|
-
# @param [String] message error message for when times out
|
|
196
|
-
#
|
|
197
|
-
# @see Watir::Wait
|
|
198
|
-
# @see Watir::Element#present?
|
|
199
|
-
#
|
|
200
|
-
|
|
201
|
-
def wait_while_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
|
|
202
|
-
timeout = depr_timeout if depr_timeout
|
|
203
|
-
Watir.logger.deprecate "#{self.class}#wait_while_present",
|
|
204
|
-
"#{self.class}#wait_while(&:present?)",
|
|
205
|
-
ids: [:wait_while_present]
|
|
206
|
-
|
|
207
|
-
message ||= proc { |obj| "waiting for #{obj.inspect} not to be present" }
|
|
208
|
-
wait_while(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
|
|
209
|
-
end
|
|
210
|
-
|
|
211
141
|
private
|
|
212
142
|
|
|
213
143
|
def create_proc(opt)
|
data/lib/watir/window.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module Watir
|
|
2
2
|
class Window
|
|
3
|
-
include EventuallyPresent
|
|
4
3
|
include Waitable
|
|
5
4
|
include Exception
|
|
6
5
|
|
|
@@ -16,7 +15,7 @@ module Watir
|
|
|
16
15
|
elsif selector.key? :handle
|
|
17
16
|
@handle = selector.delete :handle
|
|
18
17
|
else
|
|
19
|
-
return if selector.keys.all? { |k| %i[title url
|
|
18
|
+
return if selector.keys.all? { |k| %i[title url element].include? k }
|
|
20
19
|
|
|
21
20
|
raise ArgumentError, "invalid window selector: #{selector_string}"
|
|
22
21
|
end
|
|
@@ -113,7 +112,7 @@ module Watir
|
|
|
113
112
|
# Returns true if two windows are equal.
|
|
114
113
|
#
|
|
115
114
|
# @example
|
|
116
|
-
# browser.window(
|
|
115
|
+
# browser.window(title: /window_switching/) == browser.window(/closeable/)
|
|
117
116
|
# #=> false
|
|
118
117
|
#
|
|
119
118
|
# @param [Window] other
|
|
@@ -190,8 +189,6 @@ module Watir
|
|
|
190
189
|
#
|
|
191
190
|
# @api private
|
|
192
191
|
#
|
|
193
|
-
# Referenced in EventuallyPresent
|
|
194
|
-
#
|
|
195
192
|
|
|
196
193
|
def selector_string
|
|
197
194
|
@selector.inspect
|
|
@@ -204,16 +201,7 @@ module Watir
|
|
|
204
201
|
private
|
|
205
202
|
|
|
206
203
|
def locate
|
|
207
|
-
|
|
208
|
-
nil
|
|
209
|
-
elsif @selector.key?(:index)
|
|
210
|
-
Watir.logger.deprecate 'Using :index as a selector for Window', ':title or :url or :element',
|
|
211
|
-
reference: 'http://watir.com/guides/windows/#locating-by-index-is-no-longer-supported',
|
|
212
|
-
ids: [:window_index]
|
|
213
|
-
@driver.window_handles[Integer(@selector[:index])]
|
|
214
|
-
else
|
|
215
|
-
@driver.window_handles.find { |wh| matches?(wh) }
|
|
216
|
-
end
|
|
204
|
+
@selector.empty? ? nil : @driver.window_handles.find { |wh| matches?(wh) }
|
|
217
205
|
end
|
|
218
206
|
|
|
219
207
|
def assert_exists
|
|
@@ -243,13 +231,9 @@ module Watir
|
|
|
243
231
|
end
|
|
244
232
|
|
|
245
233
|
def wait_for_exists
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
wait_until(&:exists?)
|
|
250
|
-
rescue Wait::TimeoutError
|
|
251
|
-
raise NoMatchingWindowFoundException, selector_string
|
|
252
|
-
end
|
|
234
|
+
wait_until(&:exists?)
|
|
235
|
+
rescue Wait::TimeoutError
|
|
236
|
+
raise NoMatchingWindowFoundException, selector_string
|
|
253
237
|
end
|
|
254
238
|
end # Window
|
|
255
239
|
end # Watir
|
|
@@ -27,47 +27,12 @@ module Watir
|
|
|
27
27
|
alias size count
|
|
28
28
|
alias empty? none?
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
# @note windows in a collection are not ordered so this is not reliably
|
|
34
|
-
# @deprecated use Browser#switch_window or a better Window locator
|
|
35
|
-
# @return [Watir::Window] Returns an instance of a Watir::Window
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
def first
|
|
39
|
-
self[0]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
# Last window of the collection
|
|
44
|
-
#
|
|
45
|
-
# @note windows in a collection are not ordered so this is not reliably
|
|
46
|
-
# @deprecated use Browser#switch_window or a better Window locator
|
|
47
|
-
# @return [Watir::Window] Returns an instance of a Watir::Window
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
def last
|
|
51
|
-
self[-1]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
# Get the window at the given index or range.
|
|
56
|
-
#
|
|
57
|
-
# @note windows in a collection are not ordered so this is not reliably
|
|
58
|
-
# @deprecated use Browser#switch_window or a better Window locator
|
|
59
|
-
# @param [Integer, Range] value Index (0-based) or Range of desired window(s)
|
|
60
|
-
# @return [Watir::Window] Returns an instance of a Watir::Window
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
def [](value)
|
|
64
|
-
old = 'using indexing with windows'
|
|
65
|
-
new = 'Browser#switch_window or Browser#window with :title, :url or :element selectors'
|
|
66
|
-
reference = 'http://watir.com/window_indexes'
|
|
67
|
-
Watir.logger.deprecate old, new, reference: reference, ids: [:window_index]
|
|
68
|
-
|
|
69
|
-
window_list[value]
|
|
30
|
+
def [](*)
|
|
31
|
+
raise NoMethodError, 'indexing not reliable on WindowCollection'
|
|
70
32
|
end
|
|
33
|
+
alias first []
|
|
34
|
+
alias last []
|
|
35
|
+
alias to_a []
|
|
71
36
|
|
|
72
37
|
def ==(other)
|
|
73
38
|
window_list == other.send(:window_list)
|
|
@@ -78,15 +43,6 @@ module Watir
|
|
|
78
43
|
@window_list = nil
|
|
79
44
|
end
|
|
80
45
|
|
|
81
|
-
def to_a
|
|
82
|
-
old = 'WindowCollection#to_a to interact with indexed windows'
|
|
83
|
-
new = 'Enumerable methods to iterate over windows'
|
|
84
|
-
reference = 'http://watir.com/window_indexes'
|
|
85
|
-
Watir.logger.deprecate old, new, reference: reference, ids: [:window_index]
|
|
86
|
-
|
|
87
|
-
window_list
|
|
88
|
-
end
|
|
89
|
-
|
|
90
46
|
private
|
|
91
47
|
|
|
92
48
|
def window_list
|
|
@@ -19,6 +19,10 @@ module WatirSpec
|
|
|
19
19
|
@name || raise('implementation name not set')
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def browser_name
|
|
23
|
+
browser_args.first == :ie ? :internet_explorer : browser_args.first
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
def matches_guard?(args)
|
|
23
27
|
return @guard_proc.call(args) if @guard_proc
|
|
24
28
|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
|
|
4
|
-
if ENV['
|
|
4
|
+
if ENV['COVERAGE']
|
|
5
5
|
require 'coveralls'
|
|
6
6
|
require 'simplecov'
|
|
7
7
|
require 'simplecov-console'
|
|
@@ -12,7 +12,6 @@ if ENV['GITHUB_ACTIONS'] || ENV['COVERAGE']
|
|
|
12
12
|
add_filter %r{/spec/}
|
|
13
13
|
add_filter 'lib/watir/elements/html_elements.rb'
|
|
14
14
|
add_filter 'lib/watir/elements/svg_elements.rb'
|
|
15
|
-
add_filter 'lib/watir/legacy_wait.rb'
|
|
16
15
|
add_filter 'lib/watirspec'
|
|
17
16
|
refuse_coverage_drop
|
|
18
17
|
end
|
|
@@ -22,7 +21,7 @@ require 'watir'
|
|
|
22
21
|
require 'locator_spec_helper'
|
|
23
22
|
require 'rspec'
|
|
24
23
|
|
|
25
|
-
if ENV['
|
|
24
|
+
if ENV['AUTOMATIC_RETRY']
|
|
26
25
|
require 'rspec/retry'
|
|
27
26
|
RSpec.configure do |config|
|
|
28
27
|
config.verbose_retry = true
|
|
@@ -31,7 +30,3 @@ if ENV['GITHUB_ACTIONS']
|
|
|
31
30
|
config.exceptions_to_retry = [IOError, Net::ReadTimeout]
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
|
-
|
|
35
|
-
SELENIUM_SELECTORS = %i[css tag_name xpath link_text partial_link_text link].freeze
|
|
36
|
-
|
|
37
|
-
Watir.relaxed_locate = false if ENV['RELAXED_LOCATE'] == 'false'
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
require 'watirspec_helper'
|
|
2
2
|
|
|
3
3
|
describe Watir::Capabilities do
|
|
4
|
-
before
|
|
5
|
-
compliant_on :v6_18 do
|
|
6
|
-
ENV['IGNORE_DEPRECATIONS'] = 'true'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
before do
|
|
11
|
-
compliant_on :v6_18 do
|
|
12
|
-
ENV['IGNORE_DEPRECATIONS'] = 'true'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
after(:all) { ENV['IGNORE_DEPRECATIONS'] = nil }
|
|
4
|
+
before(:all) { Watir.logger.ignore(:watir_client) }
|
|
17
5
|
|
|
18
6
|
def expected_browser(browser)
|
|
19
7
|
case browser
|
|
@@ -45,25 +33,7 @@ describe Watir::Capabilities do
|
|
|
45
33
|
service_class(browser).driver_path = nil
|
|
46
34
|
end
|
|
47
35
|
|
|
48
|
-
|
|
49
|
-
compliant_on :v6_18 do
|
|
50
|
-
return Selenium::WebDriver::Remote::Http::Default
|
|
51
|
-
end
|
|
52
|
-
Watir::HttpClient
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def capabilities_key
|
|
56
|
-
compliant_on :v6_18 do
|
|
57
|
-
return :desired_capabilities
|
|
58
|
-
end
|
|
59
|
-
:capabilities
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
supported_browsers = %i[chrome firefox ie safari]
|
|
63
|
-
|
|
64
|
-
not_compliant_on :v6_18, :v6_19 do
|
|
65
|
-
supported_browsers << :edge
|
|
66
|
-
end
|
|
36
|
+
supported_browsers = %i[chrome edge firefox ie safari]
|
|
67
37
|
|
|
68
38
|
# Options:
|
|
69
39
|
# :listener
|
|
@@ -73,93 +43,38 @@ describe Watir::Capabilities do
|
|
|
73
43
|
# :capabilities (incompatible with options)
|
|
74
44
|
|
|
75
45
|
supported_browsers.each do |browser_symbol|
|
|
76
|
-
|
|
77
|
-
# 6.19 fix safari
|
|
78
|
-
# 7.0 remove Capabilities requirement
|
|
79
|
-
it 'just browser has client, options & capabilities but not service' do
|
|
80
|
-
compliant_on :v6_18 do
|
|
81
|
-
skip if browser_symbol == :safari # No extra processing needed
|
|
82
|
-
end
|
|
46
|
+
it 'just browser has client & capabilities not service' do
|
|
83
47
|
capabilities = Watir::Capabilities.new(browser_symbol)
|
|
84
48
|
|
|
85
49
|
args = capabilities.to_args
|
|
86
|
-
expect(args.last[:http_client]).to be_a
|
|
87
|
-
expect(args.last[:
|
|
88
|
-
expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
50
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
51
|
+
expect(args.last[:capabilities]).to be_a options_class(browser_symbol)
|
|
89
52
|
expect(args.last).not_to include(:service)
|
|
90
53
|
end
|
|
91
54
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# 7.0 valid
|
|
95
|
-
not_compliant_on :v6_18 do
|
|
96
|
-
it 'just options has client, options & capabilities but not service' do
|
|
97
|
-
capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)
|
|
55
|
+
it 'just options has client & options but not capabilities or service' do
|
|
56
|
+
capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)
|
|
98
57
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expect(args.last[:http_client]).to be_a default_client
|
|
102
|
-
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
103
|
-
expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
104
|
-
expect(args.last[:desired_capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
105
|
-
expect(args.last).not_to include(:service)
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# 6.18 never implemented
|
|
110
|
-
# 6.19 implement
|
|
111
|
-
# 7.0 valid
|
|
112
|
-
not_compliant_on :v6_18 do
|
|
113
|
-
it 'just capabilities has client, options & capabilities but not service' do
|
|
114
|
-
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
115
|
-
capabilities = Watir::Capabilities.new(capabilities_key => caps)
|
|
116
|
-
|
|
117
|
-
args = capabilities.to_args
|
|
58
|
+
args = capabilities.to_args
|
|
118
59
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
expect(args.last[:desired_capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
123
|
-
expect(args.last).not_to include(:service)
|
|
124
|
-
end
|
|
60
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
61
|
+
expect(args.last[:capabilities]).to be_a options_class(browser_symbol)
|
|
62
|
+
expect(args.last).not_to include(:service)
|
|
125
63
|
end
|
|
126
64
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
it 'desired_capabilities works but deprecated' do
|
|
131
|
-
expect {
|
|
132
|
-
desired_capabilities = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
133
|
-
capabilities = Watir::Capabilities.new(browser_symbol,
|
|
134
|
-
desired_capabilities: desired_capabilities)
|
|
135
|
-
args = capabilities.to_args
|
|
136
|
-
expect(args.first).to eq browser_symbol
|
|
137
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
138
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
139
|
-
expect(desired_capabilities.browser_name).to eq expected_browser(browser_symbol)
|
|
140
|
-
}.to have_deprecated_desired_capabilities
|
|
141
|
-
end
|
|
65
|
+
it 'just capabilities has client & capabilities but not service' do
|
|
66
|
+
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
67
|
+
capabilities = Watir::Capabilities.new(capabilities: caps)
|
|
142
68
|
|
|
143
|
-
|
|
144
|
-
# 6.19 fix with deprecation
|
|
145
|
-
# 7.0 raise exception
|
|
146
|
-
it 'service not allowed when url specified' do
|
|
147
|
-
halt_service(browser_symbol)
|
|
69
|
+
args = capabilities.to_args
|
|
148
70
|
|
|
149
|
-
expect
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
args = capabilities.to_args
|
|
154
|
-
expect(args.first).to eq :remote
|
|
155
|
-
expect(args.last).not_to include(:service)
|
|
156
|
-
}.to have_deprecated_url_service
|
|
71
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
72
|
+
expect(args.last[:capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
73
|
+
expect(args.last[:capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
74
|
+
expect(args.last).not_to include(:service)
|
|
157
75
|
end
|
|
158
76
|
|
|
159
77
|
context 'service' do
|
|
160
|
-
# 6.18 never implemented
|
|
161
|
-
# 6.19 implement
|
|
162
|
-
# 7.0 valid
|
|
163
78
|
it 'uses provided service' do
|
|
164
79
|
halt_service(browser_symbol)
|
|
165
80
|
|
|
@@ -171,76 +86,33 @@ describe Watir::Capabilities do
|
|
|
171
86
|
expect(actual_service.instance_variable_get('@port')).to eq 1234
|
|
172
87
|
end
|
|
173
88
|
|
|
174
|
-
|
|
175
|
-
# 6.19 implement!
|
|
176
|
-
# 7.0 valid
|
|
177
|
-
not_compliant_on :v6_18 do
|
|
178
|
-
it 'builds service from a Hash' do
|
|
179
|
-
halt_service(browser_symbol)
|
|
180
|
-
|
|
181
|
-
service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}
|
|
182
|
-
capabilities = Watir::Capabilities.new(browser_symbol, service: service)
|
|
183
|
-
args = capabilities.to_args
|
|
184
|
-
expect(args.first).to eq browser_symbol
|
|
185
|
-
actual_service = args.last[:service]
|
|
186
|
-
expect(actual_service.instance_variable_get('@port')).to eq 1234
|
|
187
|
-
expect(actual_service.instance_variable_get('@executable_path')).to eq '/path/to/driver'
|
|
188
|
-
expect(actual_service.instance_variable_get('@extra_args')).to include '--foo', '--bar'
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it 'is a bad argument to service' do
|
|
192
|
-
capabilities = Watir::Capabilities.new(browser_symbol, service: 7)
|
|
193
|
-
|
|
194
|
-
expect { capabilities.to_args }.to raise_exception(TypeError)
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
# 6.18 broken: puts it in desired capabilities (neither ":path" nor ":driver_path" work)
|
|
199
|
-
# 6.19 do nothing
|
|
200
|
-
# 7.0 remove
|
|
201
|
-
xit 'creates when :path specified' do
|
|
89
|
+
it 'builds service from a Hash' do
|
|
202
90
|
halt_service(browser_symbol)
|
|
203
|
-
capabilities = Watir::Capabilities.new(browser_symbol, path: '/path/to/driver')
|
|
204
91
|
|
|
92
|
+
service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}
|
|
93
|
+
capabilities = Watir::Capabilities.new(browser_symbol, service: service)
|
|
205
94
|
args = capabilities.to_args
|
|
206
|
-
expect(args.
|
|
95
|
+
expect(args.first).to eq browser_symbol
|
|
96
|
+
actual_service = args.last[:service]
|
|
97
|
+
expect(actual_service.instance_variable_get('@port')).to eq 1234
|
|
98
|
+
expect(actual_service.instance_variable_get('@executable_path')).to eq '/path/to/driver'
|
|
99
|
+
expect(actual_service.instance_variable_get('@extra_args')).to include '--foo', '--bar'
|
|
207
100
|
end
|
|
208
101
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
# 7.0 remove
|
|
212
|
-
it 'creates when service port specified' do
|
|
213
|
-
halt_service(browser_symbol)
|
|
102
|
+
it 'is a bad argument to service' do
|
|
103
|
+
capabilities = Watir::Capabilities.new(browser_symbol, service: 7)
|
|
214
104
|
|
|
215
|
-
expect {
|
|
216
|
-
capabilities = Watir::Capabilities.new(browser_symbol,
|
|
217
|
-
port: 1234)
|
|
218
|
-
@args = capabilities.to_args
|
|
219
|
-
}.to have_deprecated_port_keyword
|
|
220
|
-
|
|
221
|
-
compliant_on :v6_18 do
|
|
222
|
-
expect(@args.last[:port]).to eq 1234
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
not_compliant_on :v6_18 do
|
|
226
|
-
expect(@args.last[:service].instance_variable_get('@port')).to eq 1234
|
|
227
|
-
end
|
|
105
|
+
expect { capabilities.to_args }.to raise_exception(TypeError)
|
|
228
106
|
end
|
|
229
107
|
end
|
|
230
108
|
|
|
231
109
|
context 'http_client' do
|
|
232
|
-
# 6.18 works
|
|
233
|
-
# 6.19 update to Watir::HttpClient
|
|
234
|
-
# 7.0 valid
|
|
235
110
|
it 'uses default HTTP Client' do
|
|
236
111
|
capabilities = Watir::Capabilities.new(browser_symbol)
|
|
237
112
|
args = capabilities.to_args
|
|
238
|
-
expect(args.last[:http_client]).to be_a
|
|
113
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
239
114
|
end
|
|
240
115
|
|
|
241
|
-
# 6.18 works
|
|
242
|
-
# 6.19 do nothing
|
|
243
|
-
# 7.0 valid
|
|
244
116
|
it 'accepts an HTTP Client object' do
|
|
245
117
|
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
246
118
|
capabilities = Watir::Capabilities.new(browser_symbol, http_client: client)
|
|
@@ -248,68 +120,23 @@ describe Watir::Capabilities do
|
|
|
248
120
|
expect(args.last[:http_client]).to eq client
|
|
249
121
|
end
|
|
250
122
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
actual_client = args.last[:http_client]
|
|
260
|
-
expect(actual_client).to be_a default_client
|
|
261
|
-
expect(actual_client.instance_variable_get('@read_timeout')).to eq 10
|
|
262
|
-
expect(actual_client.instance_variable_get('@open_timeout')).to eq 10
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
# 6.18 Not implemented
|
|
267
|
-
# 6.19 implement!
|
|
268
|
-
# 7.0 valid
|
|
269
|
-
not_compliant_on :v6_18 do
|
|
270
|
-
it 'raises an exception if :client receives something other than Hash or Client object' do
|
|
271
|
-
expect {
|
|
272
|
-
Watir::Capabilities.new(browser_symbol, http_client: 7).to_args
|
|
273
|
-
}.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')
|
|
274
|
-
end
|
|
123
|
+
it 'builds an HTTP Client from Hash' do
|
|
124
|
+
client_opts = {open_timeout: 10, read_timeout: 10}
|
|
125
|
+
capabilities = Watir::Capabilities.new(browser_symbol, http_client: client_opts)
|
|
126
|
+
args = capabilities.to_args
|
|
127
|
+
actual_client = args.last[:http_client]
|
|
128
|
+
expect(actual_client).to be_a Watir::HttpClient
|
|
129
|
+
expect(actual_client.instance_variable_get('@read_timeout')).to eq 10
|
|
130
|
+
expect(actual_client.instance_variable_get('@open_timeout')).to eq 10
|
|
275
131
|
end
|
|
276
132
|
|
|
277
|
-
|
|
278
|
-
# 6.19 deprecate --> client_timeout isn't a thing any more
|
|
279
|
-
# 7.0 remove
|
|
280
|
-
it 'builds a client from client_timeout' do
|
|
133
|
+
it 'raises an exception if :client receives something other than Hash or Client object' do
|
|
281
134
|
expect {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
args = capabilities.to_args
|
|
285
|
-
actual_client = args.last[:http_client]
|
|
286
|
-
expect(actual_client).to be_a default_client
|
|
287
|
-
expect(actual_client.instance_variable_get('@read_timeout')).to eq 10
|
|
288
|
-
expect(actual_client.instance_variable_get('@open_timeout')).to eq 10
|
|
289
|
-
}.to have_deprecated_http_client_timeout
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
# 6.18 works
|
|
293
|
-
# 6.19 deprecate --> timeouts inside http_client key
|
|
294
|
-
# 7.0 remove
|
|
295
|
-
%i[open_timeout read_timeout].each do |timeout|
|
|
296
|
-
it "builds a client from #{timeout}" do
|
|
297
|
-
expect {
|
|
298
|
-
opt = {timeout => 10}
|
|
299
|
-
|
|
300
|
-
capabilities = Watir::Capabilities.new(browser_symbol, opt)
|
|
301
|
-
args = capabilities.to_args
|
|
302
|
-
actual_client = args.last[:http_client]
|
|
303
|
-
expect(actual_client).to be_a default_client
|
|
304
|
-
expect(actual_client.instance_variable_get("@#{timeout}")).to eq 10
|
|
305
|
-
}.to send("have_deprecated_http_#{timeout}")
|
|
306
|
-
end
|
|
135
|
+
Watir::Capabilities.new(browser_symbol, http_client: 7).to_args
|
|
136
|
+
}.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')
|
|
307
137
|
end
|
|
308
138
|
end
|
|
309
139
|
|
|
310
|
-
# 6.18 works
|
|
311
|
-
# 6.19 do nothing
|
|
312
|
-
# 7.0 valid
|
|
313
140
|
it 'uses a listener' do
|
|
314
141
|
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
315
142
|
capabilities = Watir::Capabilities.new(browser_symbol, listener: listener)
|
|
@@ -317,69 +144,13 @@ describe Watir::Capabilities do
|
|
|
317
144
|
expect(args.last[:listener]).to eq listener
|
|
318
145
|
end
|
|
319
146
|
|
|
320
|
-
# 6.18 works
|
|
321
|
-
# 6.19 warn
|
|
322
|
-
# 7.0 Raise Exception
|
|
323
147
|
it 'accepts both capabilities and Options' do
|
|
324
148
|
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
325
149
|
opts = options_class(browser_symbol).new
|
|
326
150
|
|
|
327
151
|
expect {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
options: opts)
|
|
331
|
-
}.to have_deprecated_options_capabilities
|
|
332
|
-
|
|
333
|
-
args = @capabilities.to_args
|
|
334
|
-
expect(args.last[:desired_capabilities]).to eq caps
|
|
335
|
-
|
|
336
|
-
# Safari never implemented to accept options
|
|
337
|
-
if browser_symbol == :safari
|
|
338
|
-
not_compliant_on :v6_18 do
|
|
339
|
-
expect(args.last[:options]).to eq opts
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
# 6.18 works
|
|
345
|
-
# 6.19 deprecate --> put in options
|
|
346
|
-
# 7.0 remove
|
|
347
|
-
context 'extra things' do
|
|
348
|
-
it 'puts in capabilities when capabilities not specified' do
|
|
349
|
-
expect {
|
|
350
|
-
capabilities = Watir::Capabilities.new(browser_symbol, foo: 'bar')
|
|
351
|
-
args = capabilities.to_args
|
|
352
|
-
expect(args.last[:desired_capabilities][:foo]).to eq 'bar'
|
|
353
|
-
}.to have_deprecated_unknown_keyword
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
# 6.18 works
|
|
357
|
-
# 6.19 deprecate --> put in options
|
|
358
|
-
# 7.0 remove
|
|
359
|
-
it 'puts in top level when Capabilities specified' do
|
|
360
|
-
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
361
|
-
capabilities = Watir::Capabilities.new(browser_symbol,
|
|
362
|
-
capabilities_key => caps,
|
|
363
|
-
foo: 'bar')
|
|
364
|
-
expect {
|
|
365
|
-
expect(capabilities.to_args.last[:foo]).to eq 'bar'
|
|
366
|
-
}.to have_deprecated_unknown_keyword
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
# 6.18 works
|
|
370
|
-
# 6.19 deprecate --> put in options
|
|
371
|
-
# 7.0 remove
|
|
372
|
-
it 'puts in top level when Options specified' do
|
|
373
|
-
expect {
|
|
374
|
-
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
375
|
-
capabilities = Watir::Capabilities.new(browser_symbol,
|
|
376
|
-
capabilities_key => caps,
|
|
377
|
-
options: options_class(browser_symbol).new,
|
|
378
|
-
foo: 'bar')
|
|
379
|
-
args = capabilities.to_args
|
|
380
|
-
expect(args.last[:foo]).to eq 'bar'
|
|
381
|
-
}.to have_deprecated_unknown_keyword
|
|
382
|
-
end
|
|
152
|
+
Watir::Capabilities.new(browser_symbol, capabilities: caps, options: opts)
|
|
153
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
383
154
|
end
|
|
384
155
|
end
|
|
385
156
|
|
|
@@ -392,104 +163,26 @@ describe Watir::Capabilities do
|
|
|
392
163
|
# :capabilities (incompatible with options)
|
|
393
164
|
|
|
394
165
|
describe 'Remote execution' do
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
# 7.0 Valid
|
|
398
|
-
not_compliant_on :v6_18 do
|
|
399
|
-
it 'with just url' do
|
|
400
|
-
capabilities = Watir::Capabilities.new(url: 'http://example.com')
|
|
401
|
-
args = capabilities.to_args
|
|
402
|
-
expect(args.first).to eq :remote
|
|
403
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
404
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
405
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
406
|
-
end
|
|
407
|
-
end
|
|
408
|
-
|
|
409
|
-
# 6.18 does not work
|
|
410
|
-
# 6.19 do nothing
|
|
411
|
-
# 7.0 remove
|
|
412
|
-
xit ':remote keyword with url has options, chrome and client but not service' do
|
|
413
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
414
|
-
url: 'https://example.com/wd/hub/')
|
|
166
|
+
it 'with just url' do
|
|
167
|
+
capabilities = Watir::Capabilities.new(url: 'http://example.com')
|
|
415
168
|
args = capabilities.to_args
|
|
416
169
|
expect(args.first).to eq :remote
|
|
417
|
-
|
|
418
|
-
expect(
|
|
419
|
-
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
420
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
421
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
422
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
423
|
-
expect(args.last).not_to include(:service)
|
|
170
|
+
actual_options = args.last[:capabilities]
|
|
171
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
424
172
|
end
|
|
425
173
|
|
|
426
|
-
# 6.18 works
|
|
427
|
-
# 6.19 this should use options instead of capabilities
|
|
428
|
-
# 7.0 valid
|
|
429
174
|
it 'browser name with url has capabilities and client but not service' do
|
|
430
175
|
capabilities = Watir::Capabilities.new(:firefox,
|
|
431
176
|
url: 'https://example.com/wd/hub/')
|
|
432
177
|
args = capabilities.to_args
|
|
433
178
|
expect(args.first).to eq :remote
|
|
434
179
|
expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
|
|
435
|
-
expect(args.last[:http_client]).to be_a
|
|
436
|
-
|
|
437
|
-
not_compliant_on :v6_18 do
|
|
438
|
-
expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
not_compliant_on :v6_19 do
|
|
442
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
443
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
444
|
-
expect(desired_capabilities.browser_name).to eq 'firefox'
|
|
445
|
-
end
|
|
180
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
446
181
|
|
|
182
|
+
expect(args.last[:capabilities]).to be_a Selenium::WebDriver::Firefox::Options
|
|
447
183
|
expect(args.last).not_to include(:service)
|
|
448
184
|
end
|
|
449
185
|
|
|
450
|
-
# 6.18 works
|
|
451
|
-
# 6.19 deprecate :remote_keyword
|
|
452
|
-
# 7.0 remove
|
|
453
|
-
it 'remote keyword with url and browser name' do
|
|
454
|
-
expect {
|
|
455
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
456
|
-
{browser: :firefox,
|
|
457
|
-
url: 'https://example.com'})
|
|
458
|
-
args = capabilities.to_args
|
|
459
|
-
expect(args.first).to eq :remote
|
|
460
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
461
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
462
|
-
expect(desired_capabilities.browser_name).to eq 'firefox'
|
|
463
|
-
}.to have_deprecated_remote_keyword
|
|
464
|
-
end
|
|
465
|
-
|
|
466
|
-
# 6.18 not implemented
|
|
467
|
-
# 6.19 do nothing
|
|
468
|
-
# 7.0 remove
|
|
469
|
-
xit 'remote keyword errors when given a service' do
|
|
470
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
471
|
-
url: 'http://example.com',
|
|
472
|
-
service: Selenium::WebDriver::Chrome::Service.new)
|
|
473
|
-
|
|
474
|
-
capabilities.to_args
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
# 6.18 not implemented; just ignores them
|
|
478
|
-
# 6.19 throw error
|
|
479
|
-
# 7.0 throw error
|
|
480
|
-
not_compliant_on :v6_18 do
|
|
481
|
-
it 'browser name errors when given a service' do
|
|
482
|
-
expect {
|
|
483
|
-
Watir::Capabilities.new(:chrome,
|
|
484
|
-
url: 'http://example.com',
|
|
485
|
-
service: Selenium::WebDriver::Chrome::Service.new)
|
|
486
|
-
}.to have_deprecated_url_service
|
|
487
|
-
end
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
# 6.18 works
|
|
491
|
-
# 6.19 nothing
|
|
492
|
-
# 7.0 valid
|
|
493
186
|
it 'accepts a listener' do
|
|
494
187
|
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
495
188
|
capabilities = Watir::Capabilities.new(:chrome,
|
|
@@ -499,745 +192,319 @@ describe Watir::Capabilities do
|
|
|
499
192
|
expect(args.last[:listener]).to eq listener
|
|
500
193
|
end
|
|
501
194
|
|
|
502
|
-
# 6.18 not implemented (should have defaulted to chrome)
|
|
503
|
-
# 6.19 do nothing; it never worked
|
|
504
|
-
# 7.0 remove
|
|
505
|
-
xit 'remote keyword with url and http client object' do
|
|
506
|
-
client = default_client.new
|
|
507
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
508
|
-
url: 'https://example.com/wd/hub',
|
|
509
|
-
http_client: client)
|
|
510
|
-
args = capabilities.to_args
|
|
511
|
-
expect(args.first).to eq :remote
|
|
512
|
-
expect(args.last[:http_client]).to eq client
|
|
513
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
514
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
515
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
516
|
-
end
|
|
517
|
-
|
|
518
|
-
# 6.18 works
|
|
519
|
-
# 6.19 nothing
|
|
520
|
-
# 7.0 valid
|
|
521
195
|
it 'browser name with url and http client object' do
|
|
522
|
-
client =
|
|
196
|
+
client = Watir::HttpClient.new
|
|
523
197
|
capabilities = Watir::Capabilities.new(:chrome,
|
|
524
198
|
url: 'https://example.com/wd/hub',
|
|
525
199
|
http_client: client)
|
|
526
200
|
args = capabilities.to_args
|
|
527
201
|
expect(args.first).to eq :remote
|
|
528
202
|
expect(args.last[:http_client]).to eq client
|
|
529
|
-
|
|
530
|
-
expect(
|
|
531
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
203
|
+
actual_options = args.last[:capabilities]
|
|
204
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
532
205
|
end
|
|
533
206
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
# 7.0 remove
|
|
537
|
-
xit 'remote keyword with url and http client Hash' do
|
|
538
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
207
|
+
it 'browser name with url and http client Hash' do
|
|
208
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
539
209
|
url: 'https://example.com/wd/hub',
|
|
540
|
-
|
|
210
|
+
http_client: {read_timeout: 30})
|
|
541
211
|
args = capabilities.to_args
|
|
542
212
|
expect(args.first).to eq :remote
|
|
543
213
|
expect(args.last[:http_client].instance_variable_get('@read_timeout')).to eq 30
|
|
544
|
-
|
|
545
|
-
expect(
|
|
546
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
# 6.18 not implemented - does not build from Hash
|
|
550
|
-
# 6.19 build from hash
|
|
551
|
-
# 7.0 valid
|
|
552
|
-
not_compliant_on :v6_18 do
|
|
553
|
-
it 'browser name with url and http client Hash' do
|
|
554
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
555
|
-
url: 'https://example.com/wd/hub',
|
|
556
|
-
http_client: {read_timeout: 30})
|
|
557
|
-
args = capabilities.to_args
|
|
558
|
-
expect(args.first).to eq :remote
|
|
559
|
-
expect(args.last[:http_client].instance_variable_get('@read_timeout')).to eq 30
|
|
560
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
561
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
562
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
563
|
-
end
|
|
214
|
+
actual_options = args.last[:capabilities]
|
|
215
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
564
216
|
end
|
|
565
217
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
# 7.0 remove
|
|
569
|
-
xit 'remote keyword with url and options object' do
|
|
570
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
218
|
+
it 'browser name with url and options object' do
|
|
219
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
571
220
|
url: 'https://example.com/wd/hub',
|
|
572
|
-
options: Selenium::WebDriver::Chrome::Options.new)
|
|
221
|
+
options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
|
|
573
222
|
args = capabilities.to_args
|
|
574
223
|
expect(args.first).to eq :remote
|
|
575
|
-
|
|
576
|
-
expect(
|
|
577
|
-
expect(
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
# 6.18 broken; options eaten
|
|
581
|
-
# 6.19 fix
|
|
582
|
-
# 7.0 valid
|
|
583
|
-
not_compliant_on :v6_18 do
|
|
584
|
-
it 'browser name with url and options object' do
|
|
585
|
-
opts = {args: ['--foo']}
|
|
586
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
587
|
-
url: 'https://example.com/wd/hub',
|
|
588
|
-
options: Selenium::WebDriver::Chrome::Options.new(opts))
|
|
589
|
-
args = capabilities.to_args
|
|
590
|
-
expect(args.first).to eq :remote
|
|
591
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
592
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
593
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
594
|
-
options = args.last[:options]
|
|
595
|
-
expect(options.args).to include('--foo')
|
|
596
|
-
end
|
|
224
|
+
actual_options = args.last[:capabilities]
|
|
225
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
226
|
+
expect(actual_options.args).to include('--foo')
|
|
597
227
|
end
|
|
598
228
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
xit 'remote keyword with url and options hash' do
|
|
603
|
-
capabilities = Watir::Capabilities.new(:remote,
|
|
229
|
+
it 'browser name with url and options hash' do
|
|
230
|
+
options = {prefs: {foo: 'bar'}}
|
|
231
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
604
232
|
url: 'http://example.com',
|
|
605
|
-
options:
|
|
233
|
+
options: options)
|
|
606
234
|
args = capabilities.to_args
|
|
607
235
|
expect(args.first).to eq :remote
|
|
608
236
|
expect(args.last[:url]).to eq 'http://example.com'
|
|
609
|
-
|
|
610
|
-
expect(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
# 6.18 does not work; options got dropped
|
|
614
|
-
# 6.19 fix
|
|
615
|
-
# 7.0 valid
|
|
616
|
-
not_compliant_on :v6_18 do
|
|
617
|
-
it 'browser name with url and options hash' do
|
|
618
|
-
options = {prefs: {foo: 'bar'}}
|
|
619
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
620
|
-
url: 'http://example.com',
|
|
621
|
-
options: options)
|
|
622
|
-
args = capabilities.to_args
|
|
623
|
-
expect(args.first).to eq :remote
|
|
624
|
-
expect(args.last[:url]).to eq 'http://example.com'
|
|
625
|
-
actual_options = args.last[:options]
|
|
626
|
-
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
627
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
628
|
-
end
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
# 6.18 works
|
|
632
|
-
# 6.19 deprecate :remote_keyword
|
|
633
|
-
# 7.0 remove
|
|
634
|
-
it 'remote keyword with url and capabilities' do
|
|
635
|
-
expect {
|
|
636
|
-
caps = Watir::Capabilities.new(:remote,
|
|
637
|
-
url: 'https://example.com/wd/hub',
|
|
638
|
-
capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome)
|
|
639
|
-
args = caps.to_args
|
|
640
|
-
expect(args.first).to eq :remote
|
|
641
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
642
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
643
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
644
|
-
}.to have_deprecated_remote_keyword # (and desired_capabilities)
|
|
237
|
+
actual_options = args.last[:capabilities]
|
|
238
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
239
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
645
240
|
end
|
|
646
241
|
|
|
647
|
-
# 6.18 works
|
|
648
|
-
# 6.19 nothing
|
|
649
|
-
# 7.0 valid
|
|
650
242
|
it 'browser name with url and capabilities' do
|
|
651
243
|
caps = Watir::Capabilities.new(:chrome,
|
|
652
244
|
url: 'https://example.com/wd/hub',
|
|
653
|
-
|
|
245
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome)
|
|
654
246
|
args = caps.to_args
|
|
655
247
|
expect(args.first).to eq :remote
|
|
656
|
-
|
|
657
|
-
expect(
|
|
658
|
-
expect(
|
|
248
|
+
actual_capabilities = args.last[:capabilities]
|
|
249
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
250
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
659
251
|
end
|
|
660
252
|
|
|
661
|
-
# 6.18 works
|
|
662
|
-
# 6.19 deprecate :remote_keyword
|
|
663
|
-
# 7.0 remove
|
|
664
|
-
it 'remote keyword with http client & capabilities' do
|
|
665
|
-
expect {
|
|
666
|
-
client = default_client.new
|
|
667
|
-
caps = Watir::Capabilities.new(:remote,
|
|
668
|
-
url: 'https://example.com/wd/hub',
|
|
669
|
-
capabilities_key => Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
670
|
-
http_client: client)
|
|
671
|
-
|
|
672
|
-
args = caps.to_args
|
|
673
|
-
expect(args.first).to eq :remote
|
|
674
|
-
expect(args.last[:http_client]).to eq client
|
|
675
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
676
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
677
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
678
|
-
}.to have_deprecated_remote_keyword # (and desired_capabilities)
|
|
679
|
-
end
|
|
680
|
-
|
|
681
|
-
# 6.18 works
|
|
682
|
-
# 6.19 nothing
|
|
683
|
-
# 7.0 valid
|
|
684
253
|
it 'browser name with http client & capabilities' do
|
|
685
|
-
client =
|
|
254
|
+
client = Watir::HttpClient.new
|
|
686
255
|
caps = Watir::Capabilities.new(:chrome,
|
|
687
256
|
url: 'https://example.com/wd/hub',
|
|
688
|
-
|
|
257
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
689
258
|
http_client: client)
|
|
690
259
|
|
|
691
260
|
args = caps.to_args
|
|
692
261
|
expect(args.first).to eq :remote
|
|
693
262
|
expect(args.last[:http_client]).to eq client
|
|
694
|
-
|
|
695
|
-
expect(
|
|
696
|
-
expect(
|
|
263
|
+
actual_capabilities = args.last[:capabilities]
|
|
264
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
265
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
697
266
|
end
|
|
698
267
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
expect(args.first).to eq :remote
|
|
714
|
-
expect(args.last[:http_client]).to eq client
|
|
715
|
-
actual_options = args.last[:options]
|
|
716
|
-
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
717
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
718
|
-
end
|
|
268
|
+
it 'browser name with http client & options object' do
|
|
269
|
+
client = Watir::HttpClient.new
|
|
270
|
+
options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
|
|
271
|
+
caps = Watir::Capabilities.new(:chrome,
|
|
272
|
+
url: 'https://example.com/wd/hub',
|
|
273
|
+
options: options,
|
|
274
|
+
http_client: client)
|
|
275
|
+
|
|
276
|
+
args = caps.to_args
|
|
277
|
+
expect(args.first).to eq :remote
|
|
278
|
+
expect(args.last[:http_client]).to eq client
|
|
279
|
+
actual_options = args.last[:capabilities]
|
|
280
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
281
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
719
282
|
end
|
|
720
283
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
# 7.0 raise exception
|
|
724
|
-
not_compliant_on :v6_18 do
|
|
725
|
-
it 'browser name with options & capabilities' do
|
|
726
|
-
options = {prefs: {foo: 'bar'}}
|
|
284
|
+
it 'browser name with options & capabilities' do
|
|
285
|
+
options = {prefs: {foo: 'bar'}}
|
|
727
286
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
args = @caps.to_args
|
|
736
|
-
expect(args.first).to eq :remote
|
|
737
|
-
desired_capabilities = args.last[:desired_capabilities]
|
|
738
|
-
expect(desired_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
739
|
-
expect(desired_capabilities.browser_name).to eq 'chrome'
|
|
740
|
-
actual_options = args.last[:options]
|
|
741
|
-
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
742
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
743
|
-
end
|
|
287
|
+
expect {
|
|
288
|
+
Watir::Capabilities.new(:chrome,
|
|
289
|
+
url: 'https://example.com/wd/hub',
|
|
290
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
291
|
+
options: options)
|
|
292
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
744
293
|
end
|
|
745
294
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
url: 'http://example.com')
|
|
754
|
-
args = capabilities.to_args
|
|
755
|
-
actual_options = args.last[:options]
|
|
756
|
-
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
757
|
-
end
|
|
295
|
+
it 'allows headless to be set in chrome' do
|
|
296
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
297
|
+
headless: true,
|
|
298
|
+
url: 'http://example.com')
|
|
299
|
+
args = capabilities.to_args
|
|
300
|
+
actual_options = args.last[:capabilities]
|
|
301
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
758
302
|
end
|
|
759
303
|
|
|
760
|
-
# 6.18 works - Putting it straight into Desired Capabilities. Bold move Watir 6.6. Bold move.
|
|
761
|
-
# 6.19 keep, but do this with Options instead of capabilities
|
|
762
|
-
# 7.0 valid
|
|
763
304
|
it 'allows headless to be set in firefox' do
|
|
764
305
|
capabilities = Watir::Capabilities.new(:firefox,
|
|
765
306
|
headless: true,
|
|
766
307
|
url: 'http://example.com')
|
|
767
308
|
args = capabilities.to_args
|
|
768
309
|
|
|
769
|
-
|
|
770
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
771
|
-
expect(actual_capabilities['moz:firefoxOptions']['args']).to include '--headless'
|
|
772
|
-
end
|
|
773
|
-
|
|
774
|
-
not_compliant_on :v6_18 do
|
|
775
|
-
expect(args.last[:options].args).to include '--headless'
|
|
776
|
-
end
|
|
777
|
-
end
|
|
778
|
-
|
|
779
|
-
# 6.18 works - Putting it into desired capabilities
|
|
780
|
-
# 6.19 deprecate this, it should go under options
|
|
781
|
-
# 7.0 remove
|
|
782
|
-
it 'allows sending to Browser Service Provider top level' do
|
|
783
|
-
expect {
|
|
784
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
785
|
-
'sauce:options' => {username: ENV['SAUCE_USERNAME'],
|
|
786
|
-
access_key: ENV['SAUCE_ACCESS_KEY']},
|
|
787
|
-
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
788
|
-
args = capabilities.to_args
|
|
789
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
790
|
-
expect(actual_capabilities['sauce:options'].keys).to include :username, :access_key
|
|
791
|
-
}.to have_deprecated_unknown_keyword
|
|
310
|
+
expect(args.last[:capabilities].args).to include '-headless'
|
|
792
311
|
end
|
|
793
312
|
|
|
794
|
-
# 6.18 broken; options class eats it
|
|
795
|
-
# 6.19 Fix it
|
|
796
|
-
# 7.0 valid
|
|
797
313
|
it 'allows sending to Browser Service Provider via options' do
|
|
798
|
-
not_compliant_on :v6_18 do
|
|
799
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
800
|
-
options: {'sauce:options' => {username: ENV['SAUCE_USERNAME'],
|
|
801
|
-
access_key: ENV['SAUCE_ACCESS_KEY']}},
|
|
802
|
-
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
803
|
-
args = capabilities.to_args
|
|
804
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
805
|
-
expect(actual_capabilities['sauce:options']&.keys).to include :username, :access_key
|
|
806
|
-
end
|
|
807
|
-
end
|
|
808
|
-
end
|
|
809
|
-
|
|
810
|
-
describe 'chrome' do
|
|
811
|
-
# 6.18 never implemented
|
|
812
|
-
# 6.19 implement
|
|
813
|
-
# 7.0 valid
|
|
814
|
-
not_compliant_on :v6_18 do
|
|
815
|
-
it 'by default uses chrome, has client, options & capabilities' do
|
|
816
|
-
capabilities = Watir::Capabilities.new
|
|
817
|
-
args = capabilities.to_args
|
|
818
|
-
expect(args.last[:http_client]).to be_a default_client
|
|
819
|
-
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
820
|
-
expect(args.last[:desired_capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
821
|
-
expect(args.last).not_to include(:service)
|
|
822
|
-
end
|
|
823
|
-
end
|
|
824
|
-
|
|
825
|
-
# 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read
|
|
826
|
-
# 6.19 deprecate - put inside :service keyword
|
|
827
|
-
# 7.0 remove
|
|
828
|
-
it 'creates when service driver opts specified' do
|
|
829
|
-
halt_service(:chrome)
|
|
830
|
-
|
|
831
|
-
expect {
|
|
832
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
833
|
-
driver_opts: {verbose: true})
|
|
834
|
-
@args = capabilities.to_args
|
|
835
|
-
}.to have_deprecated_driver_opts_keyword
|
|
836
|
-
|
|
837
|
-
compliant_on :v6_18 do
|
|
838
|
-
expect(@args.last[:driver_opts]).to eq(verbose: true)
|
|
839
|
-
end
|
|
840
|
-
|
|
841
|
-
not_compliant_on :v6_18 do
|
|
842
|
-
expect(@args.last[:service].instance_variable_get('@extra_args')).to eq ['--verbose']
|
|
843
|
-
end
|
|
844
|
-
end
|
|
845
|
-
|
|
846
|
-
# 6.18 works
|
|
847
|
-
# 6.19 deprecate --> put in options
|
|
848
|
-
# 7.0 remove
|
|
849
|
-
it 'places args by creating options' do
|
|
850
|
-
expect {
|
|
851
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
852
|
-
args: ['--foo'])
|
|
853
|
-
args = capabilities.to_args
|
|
854
|
-
actual_options = args.last[:options]
|
|
855
|
-
expect(actual_options.args).to include '--foo'
|
|
856
|
-
}.to have_deprecated_args_keyword
|
|
857
|
-
end
|
|
858
|
-
|
|
859
|
-
# 6.18 broken because assumes args is empty and overrides
|
|
860
|
-
# 6.19 do nothing; never worked
|
|
861
|
-
# 7.0 remove
|
|
862
|
-
xit 'places args when paired with options Hash' do
|
|
863
314
|
capabilities = Watir::Capabilities.new(:chrome,
|
|
864
|
-
|
|
865
|
-
|
|
315
|
+
options: {'sauce:options': {username: ENV['SAUCE_USERNAME'],
|
|
316
|
+
access_key: ENV['SAUCE_ACCESS_KEY']}},
|
|
317
|
+
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
866
318
|
args = capabilities.to_args
|
|
867
|
-
actual_options = args.last[:options
|
|
868
|
-
expect(actual_options
|
|
319
|
+
actual_options = args.last[:capabilities].instance_variable_get('@options')
|
|
320
|
+
expect(actual_options[:'sauce:options']).to include :username, :access_key
|
|
869
321
|
end
|
|
322
|
+
end
|
|
870
323
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
xit 'places args when paired with options object' do
|
|
875
|
-
options = Selenium::WebDriver::Chrome::Options.new(args: ['--bar'])
|
|
876
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
877
|
-
args: ['--foo'],
|
|
878
|
-
options: options)
|
|
324
|
+
describe 'chrome' do
|
|
325
|
+
it 'by default uses chrome, has client, options, but not capabilities' do
|
|
326
|
+
capabilities = Watir::Capabilities.new
|
|
879
327
|
args = capabilities.to_args
|
|
880
|
-
|
|
881
|
-
expect(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
# 6.18 works
|
|
885
|
-
# 6.19 deprecate --> no more "switches"
|
|
886
|
-
# 7.0 remove
|
|
887
|
-
it 'places switches as args by creating options' do
|
|
888
|
-
expect {
|
|
889
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
890
|
-
switches: ['--foo'])
|
|
891
|
-
args = capabilities.to_args
|
|
892
|
-
actual_options = args.last[:options]
|
|
893
|
-
expect(actual_options.args).to include '--foo'
|
|
894
|
-
}.to have_deprecated_switches_keyword
|
|
328
|
+
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
|
329
|
+
expect(args.last[:capabilities]).to be_a Selenium::WebDriver::Chrome::Options
|
|
330
|
+
expect(args.last).not_to include(:service)
|
|
895
331
|
end
|
|
896
332
|
|
|
897
|
-
# 6.18 works
|
|
898
|
-
# 6.19 allow to stay in top level
|
|
899
|
-
# 7.0 valid
|
|
900
333
|
it 'sets headless by creating options' do
|
|
901
334
|
capabilities = Watir::Capabilities.new(:chrome, headless: true)
|
|
902
335
|
args = capabilities.to_args
|
|
903
|
-
actual_options = args.last[:
|
|
336
|
+
actual_options = args.last[:capabilities]
|
|
904
337
|
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
905
338
|
end
|
|
906
339
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
headless: true)
|
|
915
|
-
args = capabilities.to_args
|
|
916
|
-
actual_options = args.last[:options]
|
|
917
|
-
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
918
|
-
end
|
|
340
|
+
it 'sets headless in existing options class' do
|
|
341
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
342
|
+
options: Selenium::WebDriver::Chrome::Options.new,
|
|
343
|
+
headless: true)
|
|
344
|
+
args = capabilities.to_args
|
|
345
|
+
actual_options = args.last[:capabilities]
|
|
346
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
919
347
|
end
|
|
920
348
|
|
|
921
|
-
# 6.18 works
|
|
922
|
-
# 6.19 allow to stay in top level
|
|
923
|
-
# 7.0 valid
|
|
924
349
|
it 'sets headless when existing options is a Hash' do
|
|
925
350
|
options = {args: ['--foo']}
|
|
926
351
|
capabilities = Watir::Capabilities.new(:chrome,
|
|
927
352
|
options: options,
|
|
928
353
|
headless: true)
|
|
929
354
|
args = capabilities.to_args
|
|
930
|
-
actual_options = args.last[:
|
|
355
|
+
actual_options = args.last[:capabilities]
|
|
931
356
|
expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
|
|
932
357
|
end
|
|
933
358
|
|
|
934
|
-
# 6.18 Working; Selenium correctly disappears any non-valid options
|
|
935
|
-
# 6.19 Keep
|
|
936
|
-
# 7.0 Valid
|
|
937
359
|
it 'generates options from Hash' do
|
|
938
360
|
options = {args: %w[--foo --bar]}
|
|
939
361
|
capabilities = Watir::Capabilities.new(:chrome, options: options)
|
|
940
362
|
args = capabilities.to_args
|
|
941
|
-
actual_options = args.last[:
|
|
363
|
+
actual_options = args.last[:capabilities]
|
|
942
364
|
expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
|
|
943
365
|
expect(actual_options.args).to include '--foo', '--bar'
|
|
944
366
|
end
|
|
945
367
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
args = capabilities.to_args
|
|
956
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
957
|
-
expect(actual_capabilities[:page_load_strategy]).to eq 'eager'
|
|
958
|
-
actual_options = args.last[:options]
|
|
959
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
960
|
-
end
|
|
368
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
369
|
+
opts = {page_load_strategy: 'eager',
|
|
370
|
+
args: %w[--foo --bar]}
|
|
371
|
+
capabilities = Watir::Capabilities.new(:chrome,
|
|
372
|
+
options: opts)
|
|
373
|
+
args = capabilities.to_args
|
|
374
|
+
actual_options = args.last[:capabilities]
|
|
375
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
376
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
961
377
|
end
|
|
962
378
|
end
|
|
963
379
|
|
|
964
380
|
describe 'firefox' do
|
|
965
|
-
# 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read
|
|
966
|
-
# 6.19 deprecate - put inside :service keyword
|
|
967
|
-
# 7.0 remove
|
|
968
|
-
it 'creates when service driver opts specified' do
|
|
969
|
-
halt_service(:firefox)
|
|
970
|
-
|
|
971
|
-
expect {
|
|
972
|
-
capabilities = Watir::Capabilities.new(:firefox,
|
|
973
|
-
driver_opts: {log: 'foo.log'})
|
|
974
|
-
@args = capabilities.to_args
|
|
975
|
-
}.to have_deprecated_driver_opts_keyword
|
|
976
|
-
|
|
977
|
-
compliant_on :v6_18 do
|
|
978
|
-
expect(@args.last[:driver_opts]).to eq(log: 'foo.log')
|
|
979
|
-
end
|
|
980
|
-
|
|
981
|
-
not_compliant_on :v6_18 do
|
|
982
|
-
expect(@args.last[:service].instance_variable_get('@extra_args')).to include '--log=foo.log'
|
|
983
|
-
end
|
|
984
|
-
end
|
|
985
|
-
|
|
986
|
-
# 6.18 Works; supposed to be deprecated already
|
|
987
|
-
# 6.19 Fix deprecation
|
|
988
|
-
# 7.0 Remove
|
|
989
|
-
not_compliant_on :v6_18 do
|
|
990
|
-
it 'puts Profile inside Options as object' do
|
|
991
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
992
|
-
options = Selenium::WebDriver::Firefox::Options.new
|
|
993
|
-
|
|
994
|
-
capabilities = Watir::Capabilities.new(:firefox, options: options, profile: profile)
|
|
995
|
-
expect {
|
|
996
|
-
actual_options = capabilities.to_args.last[:options]
|
|
997
|
-
expect(actual_options.profile).to eq profile
|
|
998
|
-
}.to have_deprecated_firefox_profile
|
|
999
|
-
end
|
|
1000
|
-
end
|
|
1001
|
-
|
|
1002
|
-
# 6.18 Works; supposed to be deprecated already
|
|
1003
|
-
# 6.19 Fix deprecation
|
|
1004
|
-
# 7.0 Remove
|
|
1005
381
|
it 'puts Profile inside Options as Hash' do
|
|
1006
382
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
1007
|
-
options = {args: ['--foo']}
|
|
383
|
+
options = {args: ['--foo'], profile: profile}
|
|
1008
384
|
|
|
1009
|
-
capabilities = Watir::Capabilities.new(:firefox, options: options
|
|
385
|
+
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
|
1010
386
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
expect(actual_options.profile).to eq profile
|
|
1015
|
-
}.to have_deprecated_firefox_profile
|
|
387
|
+
actual_options = capabilities.to_args.last[:capabilities]
|
|
388
|
+
expect(actual_options.args).to include '--foo'
|
|
389
|
+
expect(actual_options.profile).to eq profile
|
|
1016
390
|
end
|
|
1017
391
|
|
|
1018
|
-
# 6.18 Works
|
|
1019
|
-
# 6.19 Do nothing
|
|
1020
|
-
# 7.0 Valid
|
|
1021
392
|
it 'puts Profile inside Hash options' do
|
|
1022
393
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
1023
394
|
options = {args: ['--foo'], profile: profile}
|
|
1024
395
|
|
|
1025
396
|
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
|
1026
397
|
|
|
1027
|
-
actual_options = capabilities.to_args.last[:
|
|
398
|
+
actual_options = capabilities.to_args.last[:capabilities]
|
|
1028
399
|
expect(actual_options.args).to include '--foo'
|
|
1029
400
|
expect(actual_options.profile).to eq profile
|
|
1030
401
|
end
|
|
1031
402
|
|
|
1032
|
-
# 6.18 works
|
|
1033
|
-
# 6.19 allow to stay in top level
|
|
1034
|
-
# 7.0 valid
|
|
1035
403
|
it 'sets headless by creating options' do
|
|
1036
404
|
capabilities = Watir::Capabilities.new(:firefox, headless: true)
|
|
1037
405
|
args = capabilities.to_args
|
|
1038
|
-
actual_options = args.last[:
|
|
1039
|
-
expect(actual_options.args).to include '
|
|
406
|
+
actual_options = args.last[:capabilities]
|
|
407
|
+
expect(actual_options.args).to include '-headless'
|
|
1040
408
|
end
|
|
1041
409
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
headless: true)
|
|
1050
|
-
args = capabilities.to_args
|
|
1051
|
-
actual_options = args.last[:options]
|
|
1052
|
-
expect(actual_options.args).to include '--headless'
|
|
1053
|
-
end
|
|
410
|
+
it 'sets headless in existing options class' do
|
|
411
|
+
capabilities = Watir::Capabilities.new(:firefox,
|
|
412
|
+
options: Selenium::WebDriver::Firefox::Options.new,
|
|
413
|
+
headless: true)
|
|
414
|
+
args = capabilities.to_args
|
|
415
|
+
actual_options = args.last[:capabilities]
|
|
416
|
+
expect(actual_options.args).to include '-headless'
|
|
1054
417
|
end
|
|
1055
418
|
|
|
1056
|
-
# 6.18 works
|
|
1057
|
-
# 6.19 allow to stay in top level
|
|
1058
|
-
# 7.0 valid
|
|
1059
419
|
it 'sets headless when existing options is a Hash' do
|
|
1060
|
-
options = {args: ['
|
|
420
|
+
options = {args: ['-foo']}
|
|
1061
421
|
capabilities = Watir::Capabilities.new(:firefox,
|
|
1062
422
|
options: options,
|
|
1063
423
|
headless: true)
|
|
1064
424
|
args = capabilities.to_args
|
|
1065
|
-
actual_options = args.last[:
|
|
1066
|
-
expect(actual_options.args).to include '
|
|
425
|
+
actual_options = args.last[:capabilities]
|
|
426
|
+
expect(actual_options.args).to include '-headless', '-foo'
|
|
1067
427
|
end
|
|
1068
428
|
|
|
1069
|
-
# 6.18 Working
|
|
1070
|
-
# 6.19 Keep
|
|
1071
|
-
# 7.0 Valid
|
|
1072
429
|
it 'generates Options instance from Hash' do
|
|
1073
430
|
options = {args: %w[--foo --bar]}
|
|
1074
431
|
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
|
1075
432
|
args = capabilities.to_args
|
|
1076
|
-
actual_options = args.last[:
|
|
433
|
+
actual_options = args.last[:capabilities]
|
|
1077
434
|
expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
|
|
1078
435
|
expect(actual_options.args).to include '--foo', '--bar'
|
|
1079
436
|
end
|
|
1080
437
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
args = capabilities.to_args
|
|
1091
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
1092
|
-
expect(actual_capabilities[:page_load_strategy]).to eq 'eager'
|
|
1093
|
-
actual_options = args.last[:options]
|
|
1094
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
1095
|
-
end
|
|
438
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
439
|
+
opts = {page_load_strategy: 'eager',
|
|
440
|
+
args: %w[--foo --bar]}
|
|
441
|
+
capabilities = Watir::Capabilities.new(:firefox,
|
|
442
|
+
options: opts)
|
|
443
|
+
args = capabilities.to_args
|
|
444
|
+
actual_options = args.last[:capabilities]
|
|
445
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
446
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
1096
447
|
end
|
|
1097
448
|
end
|
|
1098
449
|
|
|
1099
450
|
describe 'safari' do
|
|
1100
|
-
# 6.18 works
|
|
1101
|
-
# 6.19 do nothing
|
|
1102
|
-
# 7.0 valid
|
|
1103
451
|
it 'sets Technology Preview' do
|
|
1104
452
|
halt_service(:safari)
|
|
1105
453
|
|
|
1106
454
|
Watir::Capabilities.new(:safari, technology_preview: true).to_args
|
|
1107
455
|
|
|
1108
|
-
expect(Selenium::WebDriver::Safari
|
|
1109
|
-
.to eq Selenium::WebDriver::Safari.technology_preview
|
|
456
|
+
expect(Selenium::WebDriver::Safari.technology_preview?).to eq true
|
|
1110
457
|
end
|
|
1111
458
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
args = capabilities.to_args
|
|
1120
|
-
actual_options = args.last[:options]
|
|
1121
|
-
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
|
1122
|
-
expect(actual_options.automatic_inspection).to eq true
|
|
1123
|
-
end
|
|
459
|
+
it 'generates options from Hash' do
|
|
460
|
+
options = {automatic_inspection: true}
|
|
461
|
+
capabilities = Watir::Capabilities.new(:safari, options: options)
|
|
462
|
+
args = capabilities.to_args
|
|
463
|
+
actual_options = args.last[:capabilities]
|
|
464
|
+
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
|
465
|
+
expect(actual_options.automatic_inspection).to eq true
|
|
1124
466
|
end
|
|
1125
467
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
args = capabilities.to_args
|
|
1136
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
1137
|
-
expect(actual_capabilities[:page_load_strategy]).to eq 'eager'
|
|
1138
|
-
actual_options = args.last[:options]
|
|
1139
|
-
expect(actual_options.automatic_inspection).to eq true
|
|
1140
|
-
end
|
|
468
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
469
|
+
opts = {page_load_strategy: 'eager',
|
|
470
|
+
automatic_inspection: true}
|
|
471
|
+
capabilities = Watir::Capabilities.new(:safari,
|
|
472
|
+
options: opts)
|
|
473
|
+
args = capabilities.to_args
|
|
474
|
+
actual_options = args.last[:capabilities]
|
|
475
|
+
expect(actual_options.automatic_inspection).to eq true
|
|
476
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
1141
477
|
end
|
|
1142
478
|
end
|
|
1143
479
|
|
|
1144
480
|
describe 'ie' do
|
|
1145
|
-
# 6.18 works - puts them at top level in selenium opts, which Selenium 3 can read
|
|
1146
|
-
# 6.19 deprecate - put inside :service keyword
|
|
1147
|
-
# 7.0 remove
|
|
1148
|
-
it 'creates when service driver opts specified' do
|
|
1149
|
-
halt_service(:ie)
|
|
1150
|
-
|
|
1151
|
-
expect {
|
|
1152
|
-
capabilities = Watir::Capabilities.new(:ie,
|
|
1153
|
-
driver_opts: {silent: true})
|
|
1154
|
-
@args = capabilities.to_args
|
|
1155
|
-
}.to have_deprecated_driver_opts_keyword
|
|
1156
|
-
|
|
1157
|
-
compliant_on :v6_18 do
|
|
1158
|
-
expect(@args.last[:driver_opts]).to eq(silent: true)
|
|
1159
|
-
end
|
|
1160
|
-
|
|
1161
|
-
not_compliant_on :v6_18 do
|
|
1162
|
-
expect(@args.last[:service].instance_variable_get('@extra_args')).to include '--silent'
|
|
1163
|
-
end
|
|
1164
|
-
end
|
|
1165
|
-
|
|
1166
|
-
# 6.18 Working
|
|
1167
|
-
# 6.19 Keep
|
|
1168
|
-
# 7.0 Valid
|
|
1169
481
|
it 'generates Options instance from Hash with args' do
|
|
1170
482
|
options = {args: %w[--foo --bar]}
|
|
1171
483
|
capabilities = Watir::Capabilities.new(:ie, options: options)
|
|
1172
484
|
args = capabilities.to_args
|
|
1173
|
-
actual_options = args.last[:
|
|
485
|
+
actual_options = args.last[:capabilities]
|
|
1174
486
|
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
1175
487
|
expect(actual_options.args).to include '--foo', '--bar'
|
|
1176
488
|
end
|
|
1177
489
|
|
|
1178
|
-
# 6.18 Working
|
|
1179
|
-
# 6.19 Keep
|
|
1180
|
-
# 7.0 Valid
|
|
1181
490
|
it 'generates Options instance from Hash with valid option' do
|
|
1182
491
|
options = {browser_attach_timeout: true}
|
|
1183
492
|
capabilities = Watir::Capabilities.new(:ie, options: options)
|
|
1184
493
|
args = capabilities.to_args
|
|
1185
|
-
actual_options = args.last[:
|
|
494
|
+
actual_options = args.last[:capabilities]
|
|
1186
495
|
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
1187
496
|
expect(actual_options.options[:browser_attach_timeout]).to eq true
|
|
1188
497
|
end
|
|
1189
498
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
options = Selenium::WebDriver::IE::Options.new
|
|
1196
|
-
capabilities = Watir::Capabilities.new(:ie, options: options, args: args)
|
|
1197
|
-
args = capabilities.to_args
|
|
1198
|
-
actual_options = args.last[:options]
|
|
1199
|
-
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
1200
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
1201
|
-
end
|
|
1202
|
-
|
|
1203
|
-
# 6.18 broken; overwrites args in options
|
|
1204
|
-
# 6.19 do nothing; never worked
|
|
1205
|
-
# 7.0 Remove
|
|
1206
|
-
xit 'adds args to existing options hash' do
|
|
1207
|
-
options = {args: ['--foo']}
|
|
1208
|
-
capabilities = Watir::Capabilities.new(:ie, options: options, args: ['--bar'])
|
|
499
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
500
|
+
opts = {page_load_strategy: 'eager',
|
|
501
|
+
args: ['--foo']}
|
|
502
|
+
capabilities = Watir::Capabilities.new(:ie,
|
|
503
|
+
options: opts)
|
|
1209
504
|
args = capabilities.to_args
|
|
1210
|
-
actual_options = args.last[:
|
|
1211
|
-
expect(actual_options).to
|
|
1212
|
-
expect(actual_options.
|
|
1213
|
-
end
|
|
1214
|
-
|
|
1215
|
-
# 6.18 Never implemented
|
|
1216
|
-
# 6.19 Implement
|
|
1217
|
-
# 7.0 Valid
|
|
1218
|
-
not_compliant_on :v6_18 do
|
|
1219
|
-
it 'accepts browser and w3c capabilities in options Hash' do
|
|
1220
|
-
opts = {page_load_strategy: 'eager',
|
|
1221
|
-
args: ['--foo']}
|
|
1222
|
-
capabilities = Watir::Capabilities.new(:ie,
|
|
1223
|
-
options: opts)
|
|
1224
|
-
args = capabilities.to_args
|
|
1225
|
-
actual_capabilities = args.last[:desired_capabilities]
|
|
1226
|
-
expect(actual_capabilities[:page_load_strategy]).to eq 'eager'
|
|
1227
|
-
actual_options = args.last[:options]
|
|
1228
|
-
expect(actual_options.args).to include '--foo'
|
|
1229
|
-
end
|
|
1230
|
-
end
|
|
1231
|
-
|
|
1232
|
-
# 6.18 Works
|
|
1233
|
-
# 6.19 Deprecate
|
|
1234
|
-
# 7.0 Remove
|
|
1235
|
-
it 'adds args by itself' do
|
|
1236
|
-
caps = Watir::Capabilities.new(:ie, args: %w[foo bar])
|
|
1237
|
-
expect {
|
|
1238
|
-
opts = caps.to_args.last[:options]
|
|
1239
|
-
expect(opts.args).to eq Set.new(%w[foo bar])
|
|
1240
|
-
}.to have_deprecated_args_keyword
|
|
505
|
+
actual_options = args.last[:capabilities]
|
|
506
|
+
expect(actual_options.args).to include '--foo'
|
|
507
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
1241
508
|
end
|
|
1242
509
|
end
|
|
1243
510
|
end
|