watir 7.2.0 → 7.2.1
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/workflows/chrome.yml +1 -1
- data/.github/workflows/edge.yml +1 -1
- data/.github/workflows/firefox.yml +1 -1
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/.rubocop.yml +25 -12
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +6 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +1 -1
- data/lib/watir/locators/anchor/selector_builder.rb +3 -0
- data/lib/watir/locators/element/matcher.rb +2 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
- data/lib/watir/locators/text_field/matcher.rb +0 -4
- data/lib/watir/version.rb +1 -1
- data/spec/locator_spec_helper.rb +0 -8
- data/spec/unit/capabilities_spec.rb +553 -561
- data/spec/unit/element_locator_spec.rb +89 -78
- data/spec/unit/match_elements/button_spec.rb +69 -62
- data/spec/unit/match_elements/element_spec.rb +303 -309
- data/spec/unit/match_elements/text_field_spec.rb +76 -73
- data/spec/unit/selector_builder/anchor_spec.rb +39 -33
- data/spec/unit/selector_builder/button_spec.rb +209 -202
- data/spec/unit/selector_builder/cell_spec.rb +48 -42
- data/spec/unit/selector_builder/element_spec.rb +634 -627
- data/spec/unit/selector_builder/row_spec.rb +119 -113
- data/spec/unit/selector_builder/text_field_spec.rb +195 -188
- data/spec/unit/selector_builder/textarea_spec.rb +22 -14
- data/spec/unit/wait_spec.rb +85 -81
- data/spec/watirspec/adjacent_spec.rb +249 -247
- data/spec/watirspec/after_hooks_spec.rb +161 -159
- data/spec/watirspec/alert_spec.rb +61 -58
- data/spec/watirspec/browser_spec.rb +409 -409
- data/spec/watirspec/capabilities_spec.rb +89 -99
- data/spec/watirspec/cookies_spec.rb +120 -118
- data/spec/watirspec/drag_and_drop_spec.rb +26 -24
- data/spec/watirspec/element_hidden_spec.rb +66 -60
- data/spec/watirspec/elements/area_spec.rb +49 -47
- data/spec/watirspec/elements/areas_spec.rb +27 -25
- data/spec/watirspec/elements/button_spec.rb +253 -251
- data/spec/watirspec/elements/buttons_spec.rb +36 -34
- data/spec/watirspec/elements/checkbox_spec.rb +48 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
- data/spec/watirspec/elements/collections_spec.rb +126 -119
- data/spec/watirspec/elements/date_field_spec.rb +185 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
- data/spec/watirspec/elements/dd_spec.rb +87 -85
- data/spec/watirspec/elements/dds_spec.rb +27 -25
- data/spec/watirspec/elements/del_spec.rb +106 -104
- data/spec/watirspec/elements/dels_spec.rb +26 -24
- data/spec/watirspec/elements/div_spec.rb +225 -221
- data/spec/watirspec/elements/divs_spec.rb +37 -35
- data/spec/watirspec/elements/dl_spec.rb +110 -108
- data/spec/watirspec/elements/dls_spec.rb +28 -26
- data/spec/watirspec/elements/dt_spec.rb +86 -84
- data/spec/watirspec/elements/dts_spec.rb +27 -25
- data/spec/watirspec/elements/element_spec.rb +794 -775
- data/spec/watirspec/elements/elements_spec.rb +40 -38
- data/spec/watirspec/elements/em_spec.rb +62 -60
- data/spec/watirspec/elements/ems_spec.rb +28 -26
- data/spec/watirspec/elements/filefield_spec.rb +116 -114
- data/spec/watirspec/elements/filefields_spec.rb +28 -26
- data/spec/watirspec/elements/font_spec.rb +20 -18
- data/spec/watirspec/elements/form_spec.rb +51 -49
- data/spec/watirspec/elements/forms_spec.rb +29 -27
- data/spec/watirspec/elements/frame_spec.rb +89 -87
- data/spec/watirspec/elements/frames_spec.rb +27 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -79
- data/spec/watirspec/elements/hiddens_spec.rb +28 -26
- data/spec/watirspec/elements/hn_spec.rb +59 -57
- data/spec/watirspec/elements/hns_spec.rb +26 -24
- data/spec/watirspec/elements/iframe_spec.rb +195 -191
- data/spec/watirspec/elements/iframes_spec.rb +31 -29
- data/spec/watirspec/elements/image_spec.rb +148 -146
- data/spec/watirspec/elements/images_spec.rb +26 -24
- data/spec/watirspec/elements/input_spec.rb +9 -7
- data/spec/watirspec/elements/ins_spec.rb +106 -104
- data/spec/watirspec/elements/inses_spec.rb +26 -24
- data/spec/watirspec/elements/label_spec.rb +56 -54
- data/spec/watirspec/elements/labels_spec.rb +26 -24
- data/spec/watirspec/elements/li_spec.rb +76 -74
- data/spec/watirspec/elements/link_spec.rb +173 -177
- data/spec/watirspec/elements/links_spec.rb +45 -43
- data/spec/watirspec/elements/lis_spec.rb +27 -25
- data/spec/watirspec/elements/list_spec.rb +44 -42
- data/spec/watirspec/elements/map_spec.rb +57 -55
- data/spec/watirspec/elements/maps_spec.rb +27 -25
- data/spec/watirspec/elements/meta_spec.rb +16 -14
- data/spec/watirspec/elements/metas_spec.rb +26 -24
- data/spec/watirspec/elements/ol_spec.rb +56 -65
- data/spec/watirspec/elements/ols_spec.rb +26 -24
- data/spec/watirspec/elements/option_spec.rb +91 -89
- data/spec/watirspec/elements/p_spec.rb +81 -79
- data/spec/watirspec/elements/pre_spec.rb +77 -75
- data/spec/watirspec/elements/pres_spec.rb +26 -24
- data/spec/watirspec/elements/ps_spec.rb +26 -24
- data/spec/watirspec/elements/radio_spec.rb +251 -249
- data/spec/watirspec/elements/radios_spec.rb +28 -26
- data/spec/watirspec/elements/select_list_spec.rb +537 -526
- data/spec/watirspec/elements/select_lists_spec.rb +32 -30
- data/spec/watirspec/elements/span_spec.rb +112 -110
- data/spec/watirspec/elements/spans_spec.rb +26 -24
- data/spec/watirspec/elements/strong_spec.rb +58 -58
- data/spec/watirspec/elements/strongs_spec.rb +28 -26
- data/spec/watirspec/elements/table_spec.rb +192 -139
- data/spec/watirspec/elements/tables_spec.rb +28 -26
- data/spec/watirspec/elements/tbody_spec.rb +74 -72
- data/spec/watirspec/elements/tbodys_spec.rb +40 -38
- data/spec/watirspec/elements/td_spec.rb +66 -64
- data/spec/watirspec/elements/tds_spec.rb +41 -39
- data/spec/watirspec/elements/text_field_spec.rb +206 -204
- data/spec/watirspec/elements/text_fields_spec.rb +30 -28
- data/spec/watirspec/elements/textarea_spec.rb +20 -18
- data/spec/watirspec/elements/textareas_spec.rb +18 -16
- data/spec/watirspec/elements/tfoot_spec.rb +65 -63
- data/spec/watirspec/elements/tfoots_spec.rb +42 -40
- data/spec/watirspec/elements/thead_spec.rb +65 -63
- data/spec/watirspec/elements/theads_spec.rb +42 -40
- data/spec/watirspec/elements/tr_spec.rb +48 -46
- data/spec/watirspec/elements/trs_spec.rb +42 -40
- data/spec/watirspec/elements/ul_spec.rb +56 -54
- data/spec/watirspec/elements/uls_spec.rb +26 -24
- data/spec/watirspec/radio_set_spec.rb +269 -267
- data/spec/watirspec/screenshot_spec.rb +20 -18
- data/spec/watirspec/scroll_spec.rb +152 -148
- data/spec/watirspec/shadow_root_spec.rb +86 -83
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +422 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +5 -4
- metadata +44 -33
- data/spec/watirspec/attributes_spec.rb +0 -18
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
- data/spec/watirspec/special_chars_spec.rb +0 -23
|
@@ -2,678 +2,670 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'unit_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe Capabilities do
|
|
7
|
+
before(:all) { Watir.logger.ignore(:watir_client) }
|
|
8
|
+
|
|
9
|
+
def expected_browser(browser)
|
|
10
|
+
case browser
|
|
11
|
+
when :ie
|
|
12
|
+
'internet explorer'
|
|
13
|
+
when :edge
|
|
14
|
+
'MicrosoftEdge'
|
|
15
|
+
else
|
|
16
|
+
browser.to_s
|
|
17
|
+
end
|
|
16
18
|
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def service_class(browser)
|
|
20
|
-
Selenium.const_get("Selenium::WebDriver::#{expected_browser_class(browser)}::Service")
|
|
21
|
-
end
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def expected_browser_class(browser)
|
|
28
|
-
browser == :ie ? 'IE' : browser.capitalize
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def halt_service(browser)
|
|
32
|
-
allow(Selenium::WebDriver::Platform).to receive(:find_binary).and_return(true)
|
|
33
|
-
allow(File).to receive(:file?).and_return(true)
|
|
34
|
-
allow(File).to receive(:executable?).and_return(true)
|
|
35
|
-
service_class(browser).driver_path = nil
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
supported_browsers = %i[chrome edge firefox ie safari]
|
|
39
|
-
|
|
40
|
-
# Options:
|
|
41
|
-
# :listener
|
|
42
|
-
# :service (Built from Hash)
|
|
43
|
-
# :http_client (Generated or Built from Hash)
|
|
44
|
-
# :proxy (Built from Hash and added to :options)
|
|
45
|
-
# :options (Generated or Built from Hash)
|
|
46
|
-
# :capabilities (incompatible with options)
|
|
20
|
+
def service_class(browser)
|
|
21
|
+
Selenium.const_get("Selenium::WebDriver::#{expected_browser_class(browser)}::Service")
|
|
22
|
+
end
|
|
47
23
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
def options_class(browser)
|
|
25
|
+
Selenium.const_get("Selenium::WebDriver::#{expected_browser_class(browser)}::Options")
|
|
26
|
+
end
|
|
51
27
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
55
|
-
expect(args.last).not_to include(:service)
|
|
28
|
+
def expected_browser_class(browser)
|
|
29
|
+
browser == :ie ? 'IE' : browser.capitalize
|
|
56
30
|
end
|
|
57
31
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}.to raise_exception(ArgumentError, ':url and :service are not both allowed')
|
|
32
|
+
def halt_service(browser)
|
|
33
|
+
allow(Selenium::WebDriver::Platform).to receive(:find_binary).and_return(true)
|
|
34
|
+
allow(File).to receive(:file?).and_return(true)
|
|
35
|
+
allow(File).to receive(:executable?).and_return(true)
|
|
36
|
+
service_class(browser).driver_path = nil
|
|
64
37
|
end
|
|
65
38
|
|
|
66
|
-
|
|
67
|
-
capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)
|
|
39
|
+
supported_browsers = %i[chrome edge firefox ie safari]
|
|
68
40
|
|
|
69
|
-
|
|
41
|
+
# Options:
|
|
42
|
+
# :listener
|
|
43
|
+
# :service (Built from Hash)
|
|
44
|
+
# :http_client (Generated or Built from Hash)
|
|
45
|
+
# :proxy (Built from Hash and added to :options)
|
|
46
|
+
# :options (Generated or Built from Hash)
|
|
47
|
+
# :capabilities (incompatible with options)
|
|
70
48
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
49
|
+
supported_browsers.each do |browser_symbol|
|
|
50
|
+
it 'just browser has client & options not service' do
|
|
51
|
+
capabilities = described_class.new(browser_symbol)
|
|
75
52
|
|
|
76
|
-
it 'just capabilities has client & capabilities but not service' do
|
|
77
|
-
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
78
|
-
capabilities = Watir::Capabilities.new(capabilities: caps)
|
|
79
|
-
args = []
|
|
80
|
-
expect {
|
|
81
53
|
args = capabilities.to_args
|
|
82
|
-
|
|
54
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
55
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
56
|
+
expect(args.last).not_to include(:service)
|
|
57
|
+
end
|
|
83
58
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
59
|
+
it 'errors with url and service' do
|
|
60
|
+
expect {
|
|
61
|
+
described_class.new(browser_symbol,
|
|
62
|
+
service: instance_double(Selenium::WebDriver::Service),
|
|
63
|
+
url: 'https://example.com/wd/hub/')
|
|
64
|
+
}.to raise_exception(ArgumentError, ':url and :service are not both allowed')
|
|
65
|
+
end
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
halt_service(browser_symbol)
|
|
67
|
+
it 'just options has client & options but not capabilities or service' do
|
|
68
|
+
capabilities = described_class.new(options: options_class(browser_symbol).new)
|
|
93
69
|
|
|
94
|
-
service = service_class(browser_symbol).new(port: 1234)
|
|
95
|
-
capabilities = Watir::Capabilities.new(browser_symbol, service: service)
|
|
96
70
|
args = capabilities.to_args
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(
|
|
71
|
+
|
|
72
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
73
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
74
|
+
expect(args.last).not_to include(:service)
|
|
100
75
|
end
|
|
101
76
|
|
|
102
|
-
it '
|
|
103
|
-
|
|
77
|
+
it 'just capabilities has client & capabilities but not service' do
|
|
78
|
+
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
79
|
+
capabilities = described_class.new(capabilities: caps)
|
|
80
|
+
args = []
|
|
81
|
+
expect {
|
|
82
|
+
args = capabilities.to_args
|
|
83
|
+
}.to have_deprecated(:capabilities)
|
|
104
84
|
|
|
105
|
-
|
|
106
|
-
capabilities
|
|
107
|
-
args
|
|
108
|
-
expect(args.
|
|
109
|
-
actual_service = args.last[:service]
|
|
110
|
-
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
111
|
-
expect(actual_service.instance_variable_get(:@executable_path)).to eq '/path/to/driver'
|
|
112
|
-
expect(actual_service.instance_variable_get(:@extra_args)).to include '--foo', '--bar'
|
|
85
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
86
|
+
expect(args.last[:capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
87
|
+
expect(args.last[:capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
88
|
+
expect(args.last).not_to include(:service)
|
|
113
89
|
end
|
|
114
90
|
|
|
115
|
-
|
|
116
|
-
|
|
91
|
+
describe 'service' do
|
|
92
|
+
it 'uses provided service' do
|
|
93
|
+
halt_service(browser_symbol)
|
|
94
|
+
|
|
95
|
+
service = service_class(browser_symbol).new(port: 1234)
|
|
96
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
97
|
+
args = capabilities.to_args
|
|
98
|
+
expect(args.first).to eq browser_symbol
|
|
99
|
+
actual_service = args.last[:service]
|
|
100
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'builds service from a Hash' do
|
|
104
|
+
halt_service(browser_symbol)
|
|
105
|
+
|
|
106
|
+
service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}
|
|
107
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
108
|
+
args = capabilities.to_args
|
|
109
|
+
expect(args.first).to eq browser_symbol
|
|
110
|
+
actual_service = args.last[:service]
|
|
111
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
112
|
+
expect(actual_service.instance_variable_get(:@executable_path)).to eq '/path/to/driver'
|
|
113
|
+
expect(actual_service.instance_variable_get(:@extra_args)).to include '--foo', '--bar'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'is a bad argument to service' do
|
|
117
|
+
capabilities = described_class.new(browser_symbol, service: 7)
|
|
118
|
+
|
|
119
|
+
expect { capabilities.to_args }.to raise_exception(TypeError)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
describe 'http_client' do
|
|
124
|
+
it 'uses default HTTP Client' do
|
|
125
|
+
capabilities = described_class.new(browser_symbol)
|
|
126
|
+
args = capabilities.to_args
|
|
127
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'accepts an HTTP Client object' do
|
|
131
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
132
|
+
capabilities = described_class.new(browser_symbol, http_client: client)
|
|
133
|
+
args = capabilities.to_args
|
|
134
|
+
expect(args.last[:http_client]).to eq client
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'builds an HTTP Client from Hash' do
|
|
138
|
+
client_opts = {open_timeout: 10, read_timeout: 10}
|
|
139
|
+
capabilities = described_class.new(browser_symbol, http_client: client_opts)
|
|
140
|
+
args = capabilities.to_args
|
|
141
|
+
actual_client = args.last[:http_client]
|
|
142
|
+
expect(actual_client).to be_a HttpClient
|
|
143
|
+
expect(actual_client.instance_variable_get(:@read_timeout)).to eq 10
|
|
144
|
+
expect(actual_client.instance_variable_get(:@open_timeout)).to eq 10
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'raises an exception if :client receives something other than Hash or Client object' do
|
|
148
|
+
expect {
|
|
149
|
+
described_class.new(browser_symbol, http_client: 7).to_args
|
|
150
|
+
}.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')
|
|
151
|
+
end
|
|
119
152
|
end
|
|
120
|
-
end
|
|
121
153
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
capabilities =
|
|
154
|
+
it 'uses a listener' do
|
|
155
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
156
|
+
capabilities = described_class.new(browser_symbol, listener: listener)
|
|
125
157
|
args = capabilities.to_args
|
|
126
|
-
expect(args.last[:
|
|
158
|
+
expect(args.last[:listener]).to eq listener
|
|
127
159
|
end
|
|
128
160
|
|
|
129
|
-
it 'accepts
|
|
130
|
-
|
|
131
|
-
|
|
161
|
+
it 'accepts both capabilities and Options' do
|
|
162
|
+
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
|
163
|
+
opts = options_class(browser_symbol).new
|
|
164
|
+
|
|
165
|
+
expect {
|
|
166
|
+
described_class.new(browser_symbol, capabilities: caps, options: opts)
|
|
167
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe 'timeout options' do
|
|
171
|
+
it 'accepts page load and script timeouts in seconds' do
|
|
172
|
+
options = {page_load_timeout: 11,
|
|
173
|
+
script_timeout: 12}
|
|
174
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
175
|
+
args = capabilities.to_args
|
|
176
|
+
actual_options = args.last[:options]
|
|
177
|
+
expect(actual_options.timeouts[:page_load]).to eq 11_000
|
|
178
|
+
expect(actual_options.timeouts[:script]).to eq 12_000
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'has deprecated timeouts key with page load warning' do
|
|
182
|
+
options = {timeouts: {page_load: 11}}
|
|
183
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
184
|
+
expect {
|
|
185
|
+
capabilities.to_args
|
|
186
|
+
}.to have_deprecated(:timeouts)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'has deprecated timeouts key with script warning' do
|
|
190
|
+
options = {timeouts: {script: 11}}
|
|
191
|
+
expect {
|
|
192
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
193
|
+
capabilities.to_args
|
|
194
|
+
}.to have_deprecated(:timeouts)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'does not allow implicit wait timeout in timeouts hash' do
|
|
198
|
+
options = {timeouts: {implicit: 1}}
|
|
199
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
200
|
+
expect {
|
|
201
|
+
capabilities.to_args
|
|
202
|
+
}.to raise_exception(ArgumentError, 'do not set implicit wait, Watir handles waiting automatically')
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'unhandled prompt behavior defaults to ignore' do
|
|
207
|
+
capabilities = described_class.new(browser_symbol)
|
|
132
208
|
args = capabilities.to_args
|
|
133
|
-
|
|
209
|
+
actual_options = args.last[:options]
|
|
210
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :ignore
|
|
134
211
|
end
|
|
135
212
|
|
|
136
|
-
it '
|
|
137
|
-
|
|
138
|
-
capabilities = Watir::Capabilities.new(browser_symbol, http_client: client_opts)
|
|
213
|
+
it 'unhandled prompt behavior can be overridden' do
|
|
214
|
+
capabilities = described_class.new(browser_symbol, options: {unhandled_prompt_behavior: :accept_and_notify})
|
|
139
215
|
args = capabilities.to_args
|
|
140
|
-
|
|
141
|
-
expect(
|
|
142
|
-
expect(actual_client.instance_variable_get(:@read_timeout)).to eq 10
|
|
143
|
-
expect(actual_client.instance_variable_get(:@open_timeout)).to eq 10
|
|
216
|
+
actual_options = args.last[:options]
|
|
217
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
|
|
144
218
|
end
|
|
145
219
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
220
|
+
describe 'proxy' do
|
|
221
|
+
it 'adds Selenium Proxy to empty Options' do
|
|
222
|
+
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
223
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
224
|
+
args = capabilities.to_args
|
|
225
|
+
proxy = args.last[:options].proxy
|
|
226
|
+
|
|
227
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
228
|
+
expect(proxy.type).to eq(:manual)
|
|
229
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
230
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
it 'builds a Proxy from Hash for Options' do
|
|
234
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
235
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
236
|
+
args = capabilities.to_args
|
|
237
|
+
proxy = args.last[:options].proxy
|
|
238
|
+
|
|
239
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
240
|
+
expect(proxy.type).to eq(:manual)
|
|
241
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
242
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'builds a Proxy from Hash and adds to Options' do
|
|
246
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
247
|
+
options = {unhandled_prompt_behavior: :accept,
|
|
248
|
+
page_load_strategy: :eager}
|
|
249
|
+
|
|
250
|
+
capabilities = described_class.new(browser_symbol, options: options, proxy: proxy)
|
|
251
|
+
args = capabilities.to_args
|
|
252
|
+
actual_options = args.last[:options]
|
|
253
|
+
|
|
254
|
+
expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
|
|
255
|
+
expect(actual_options.proxy.type).to eq(:manual)
|
|
256
|
+
expect(actual_options.proxy.http).to eq('127.0.0.1:8080')
|
|
257
|
+
expect(actual_options.proxy.ssl).to eq('127.0.0.1:443')
|
|
258
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :accept
|
|
259
|
+
expect(actual_options.page_load_strategy).to eq :eager
|
|
260
|
+
end
|
|
150
261
|
end
|
|
151
|
-
end
|
|
152
262
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
args = capabilities.to_args
|
|
157
|
-
expect(args.last[:listener]).to eq listener
|
|
158
|
-
end
|
|
263
|
+
it 'errors on bad proxy key' do
|
|
264
|
+
proxy = {bad_key: 'foo'}
|
|
265
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
159
266
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
opts = options_class(browser_symbol).new
|
|
267
|
+
expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
|
|
268
|
+
end
|
|
163
269
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
270
|
+
it 'errors on bad proxy object' do
|
|
271
|
+
capabilities = described_class.new(browser_symbol, proxy: 7)
|
|
272
|
+
expect {
|
|
273
|
+
capabilities.to_args
|
|
274
|
+
}.to raise_exception(TypeError, '7 needs to be Selenium Proxy or Hash instance')
|
|
275
|
+
end
|
|
167
276
|
end
|
|
168
277
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
278
|
+
# Options:
|
|
279
|
+
# :url (Required)
|
|
280
|
+
# :service (Errors)
|
|
281
|
+
# :listener
|
|
282
|
+
# :http_client (Generated or Built from Hash)
|
|
283
|
+
# :proxy (Built from Hash and added to :options)
|
|
284
|
+
# :options (Generated or Built from Hash)
|
|
285
|
+
# :capabilities (incompatible with options)
|
|
286
|
+
|
|
287
|
+
describe 'Remote execution' do
|
|
288
|
+
it 'with just url' do
|
|
289
|
+
capabilities = described_class.new(url: 'http://example.com')
|
|
174
290
|
args = capabilities.to_args
|
|
291
|
+
expect(args.first).to eq :remote
|
|
175
292
|
actual_options = args.last[:options]
|
|
176
|
-
expect(actual_options.
|
|
177
|
-
expect(actual_options.timeouts[:script]).to eq 12_000
|
|
293
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
178
294
|
end
|
|
179
295
|
|
|
180
|
-
it 'has
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
296
|
+
it 'just url & browser name has capabilities and client but not service' do
|
|
297
|
+
capabilities = described_class.new(:firefox,
|
|
298
|
+
url: 'https://example.com/wd/hub/')
|
|
299
|
+
args = capabilities.to_args
|
|
300
|
+
expect(args.first).to eq :remote
|
|
301
|
+
expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
|
|
302
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
187
303
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
expect {
|
|
191
|
-
capabilities = Watir::Capabilities.new(browser_symbol, options: options)
|
|
192
|
-
capabilities.to_args
|
|
193
|
-
}.to have_deprecated(:timeouts)
|
|
304
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options
|
|
305
|
+
expect(args.last).not_to include(:service)
|
|
194
306
|
end
|
|
195
307
|
|
|
196
|
-
it '
|
|
197
|
-
|
|
198
|
-
capabilities =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
308
|
+
it 'accepts a listener' do
|
|
309
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
310
|
+
capabilities = described_class.new(:chrome,
|
|
311
|
+
url: 'http://example.com/wd/hub/',
|
|
312
|
+
listener: listener)
|
|
313
|
+
args = capabilities.to_args
|
|
314
|
+
expect(args.last[:listener]).to eq listener
|
|
202
315
|
end
|
|
203
|
-
end
|
|
204
316
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
317
|
+
it 'accepts http client object' do
|
|
318
|
+
client = HttpClient.new
|
|
319
|
+
capabilities = described_class.new(:chrome,
|
|
320
|
+
url: 'https://example.com/wd/hub',
|
|
321
|
+
http_client: client)
|
|
322
|
+
args = capabilities.to_args
|
|
323
|
+
expect(args.first).to eq :remote
|
|
324
|
+
expect(args.last[:http_client]).to eq client
|
|
325
|
+
actual_options = args.last[:options]
|
|
326
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
327
|
+
end
|
|
211
328
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
329
|
+
it 'accepts http client Hash' do
|
|
330
|
+
capabilities = described_class.new(:chrome,
|
|
331
|
+
url: 'https://example.com/wd/hub',
|
|
332
|
+
http_client: {read_timeout: 30})
|
|
333
|
+
args = capabilities.to_args
|
|
334
|
+
expect(args.first).to eq :remote
|
|
335
|
+
expect(args.last[:http_client].instance_variable_get(:@read_timeout)).to eq 30
|
|
336
|
+
actual_options = args.last[:options]
|
|
337
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
338
|
+
end
|
|
218
339
|
|
|
219
|
-
|
|
220
|
-
it 'adds Selenium Proxy to empty Options' do
|
|
340
|
+
it 'accepts proxy object' do
|
|
221
341
|
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
222
|
-
capabilities =
|
|
342
|
+
capabilities = described_class.new(:chrome,
|
|
343
|
+
url: 'https://example.com/wd/hub',
|
|
344
|
+
proxy: proxy)
|
|
223
345
|
args = capabilities.to_args
|
|
346
|
+
expect(args.first).to eq :remote
|
|
224
347
|
proxy = args.last[:options].proxy
|
|
225
|
-
|
|
226
348
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
227
349
|
expect(proxy.type).to eq(:manual)
|
|
228
350
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
229
351
|
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
230
352
|
end
|
|
231
353
|
|
|
232
|
-
it '
|
|
354
|
+
it 'accepts proxy Hash' do
|
|
233
355
|
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
234
|
-
capabilities =
|
|
356
|
+
capabilities = described_class.new(:chrome,
|
|
357
|
+
url: 'https://example.com/wd/hub',
|
|
358
|
+
proxy: proxy)
|
|
235
359
|
args = capabilities.to_args
|
|
360
|
+
expect(args.first).to eq :remote
|
|
236
361
|
proxy = args.last[:options].proxy
|
|
237
|
-
|
|
238
362
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
239
363
|
expect(proxy.type).to eq(:manual)
|
|
240
364
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
241
365
|
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
242
366
|
end
|
|
243
367
|
|
|
244
|
-
it '
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
capabilities = Watir::Capabilities.new(browser_symbol, options: options, proxy: proxy)
|
|
368
|
+
it 'accepts options object' do
|
|
369
|
+
capabilities = described_class.new(:chrome,
|
|
370
|
+
url: 'https://example.com/wd/hub',
|
|
371
|
+
options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
|
|
250
372
|
args = capabilities.to_args
|
|
373
|
+
expect(args.first).to eq :remote
|
|
251
374
|
actual_options = args.last[:options]
|
|
252
|
-
|
|
253
|
-
expect(actual_options.
|
|
254
|
-
expect(actual_options.proxy.type).to eq(:manual)
|
|
255
|
-
expect(actual_options.proxy.http).to eq('127.0.0.1:8080')
|
|
256
|
-
expect(actual_options.proxy.ssl).to eq('127.0.0.1:443')
|
|
257
|
-
expect(actual_options.unhandled_prompt_behavior).to eq :accept
|
|
258
|
-
expect(actual_options.page_load_strategy).to eq :eager
|
|
375
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
376
|
+
expect(actual_options.args).to include('--foo')
|
|
259
377
|
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
it 'errors on bad proxy key' do
|
|
263
|
-
proxy = {bad_key: 'foo'}
|
|
264
|
-
capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
|
|
265
|
-
|
|
266
|
-
expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
it 'errors on bad proxy object' do
|
|
270
|
-
capabilities = Watir::Capabilities.new(browser_symbol, proxy: 7)
|
|
271
|
-
expect {
|
|
272
|
-
capabilities.to_args
|
|
273
|
-
}.to raise_exception(TypeError, '7 needs to be Selenium Proxy or Hash instance')
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
# Options:
|
|
278
|
-
# :url (Required)
|
|
279
|
-
# :service (Errors)
|
|
280
|
-
# :listener
|
|
281
|
-
# :http_client (Generated or Built from Hash)
|
|
282
|
-
# :proxy (Built from Hash and added to :options)
|
|
283
|
-
# :options (Generated or Built from Hash)
|
|
284
|
-
# :capabilities (incompatible with options)
|
|
285
|
-
|
|
286
|
-
describe 'Remote execution' do
|
|
287
|
-
it 'with just url' do
|
|
288
|
-
capabilities = Watir::Capabilities.new(url: 'http://example.com')
|
|
289
|
-
args = capabilities.to_args
|
|
290
|
-
expect(args.first).to eq :remote
|
|
291
|
-
actual_options = args.last[:options]
|
|
292
|
-
expect(actual_options.browser_name).to eq 'chrome'
|
|
293
|
-
end
|
|
294
378
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
it 'accepts a listener' do
|
|
308
|
-
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
309
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
310
|
-
url: 'http://example.com/wd/hub/',
|
|
311
|
-
listener: listener)
|
|
312
|
-
args = capabilities.to_args
|
|
313
|
-
expect(args.last[:listener]).to eq listener
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
it 'accepts http client object' do
|
|
317
|
-
client = Watir::HttpClient.new
|
|
318
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
319
|
-
url: 'https://example.com/wd/hub',
|
|
320
|
-
http_client: client)
|
|
321
|
-
args = capabilities.to_args
|
|
322
|
-
expect(args.first).to eq :remote
|
|
323
|
-
expect(args.last[:http_client]).to eq client
|
|
324
|
-
actual_options = args.last[:options]
|
|
325
|
-
expect(actual_options.browser_name).to eq 'chrome'
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
it 'accepts http client Hash' do
|
|
329
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
330
|
-
url: 'https://example.com/wd/hub',
|
|
331
|
-
http_client: {read_timeout: 30})
|
|
332
|
-
args = capabilities.to_args
|
|
333
|
-
expect(args.first).to eq :remote
|
|
334
|
-
expect(args.last[:http_client].instance_variable_get(:@read_timeout)).to eq 30
|
|
335
|
-
actual_options = args.last[:options]
|
|
336
|
-
expect(actual_options.browser_name).to eq 'chrome'
|
|
337
|
-
end
|
|
338
|
-
|
|
339
|
-
it 'accepts proxy object' do
|
|
340
|
-
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
341
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
342
|
-
url: 'https://example.com/wd/hub',
|
|
343
|
-
proxy: proxy)
|
|
344
|
-
args = capabilities.to_args
|
|
345
|
-
expect(args.first).to eq :remote
|
|
346
|
-
proxy = args.last[:options].proxy
|
|
347
|
-
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
348
|
-
expect(proxy.type).to eq(:manual)
|
|
349
|
-
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
350
|
-
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
351
|
-
end
|
|
379
|
+
it 'accepts options hash' do
|
|
380
|
+
options = {prefs: {foo: 'bar'}}
|
|
381
|
+
capabilities = described_class.new(:chrome,
|
|
382
|
+
url: 'http://example.com',
|
|
383
|
+
options: options)
|
|
384
|
+
args = capabilities.to_args
|
|
385
|
+
expect(args.first).to eq :remote
|
|
386
|
+
expect(args.last[:url]).to eq 'http://example.com'
|
|
387
|
+
actual_options = args.last[:options]
|
|
388
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
389
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
390
|
+
end
|
|
352
391
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
362
|
-
expect(proxy.type).to eq(:manual)
|
|
363
|
-
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
364
|
-
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
365
|
-
end
|
|
392
|
+
it 'accepts capabilities object' do
|
|
393
|
+
caps = described_class.new(:chrome,
|
|
394
|
+
url: 'https://example.com/wd/hub',
|
|
395
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome)
|
|
396
|
+
args = []
|
|
397
|
+
expect {
|
|
398
|
+
args = caps.to_args
|
|
399
|
+
}.to have_deprecated(:capabilities)
|
|
366
400
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
expect(args.first).to eq :remote
|
|
373
|
-
actual_options = args.last[:options]
|
|
374
|
-
expect(actual_options.browser_name).to eq 'chrome'
|
|
375
|
-
expect(actual_options.args).to include('--foo')
|
|
376
|
-
end
|
|
401
|
+
expect(args.first).to eq :remote
|
|
402
|
+
actual_capabilities = args.last[:capabilities]
|
|
403
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
404
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
405
|
+
end
|
|
377
406
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
389
|
-
end
|
|
407
|
+
it 'accepts http client & capabilities objects' do
|
|
408
|
+
client = HttpClient.new
|
|
409
|
+
caps = described_class.new(:chrome,
|
|
410
|
+
url: 'https://example.com/wd/hub',
|
|
411
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
412
|
+
http_client: client)
|
|
413
|
+
args = []
|
|
414
|
+
expect {
|
|
415
|
+
args = caps.to_args
|
|
416
|
+
}.to have_deprecated(:capabilities)
|
|
390
417
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
args = caps.to_args
|
|
398
|
-
}.to have_deprecated(:capabilities)
|
|
418
|
+
expect(args.first).to eq :remote
|
|
419
|
+
expect(args.last[:http_client]).to eq client
|
|
420
|
+
actual_capabilities = args.last[:capabilities]
|
|
421
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
422
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
423
|
+
end
|
|
399
424
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
425
|
+
it 'accepts http client & proxy & options objects' do
|
|
426
|
+
client = HttpClient.new
|
|
427
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
428
|
+
options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
|
|
429
|
+
caps = described_class.new(:chrome,
|
|
430
|
+
url: 'https://example.com/wd/hub',
|
|
431
|
+
proxy: proxy,
|
|
432
|
+
options: options,
|
|
433
|
+
http_client: client)
|
|
405
434
|
|
|
406
|
-
it 'accepts http client & capabilities objects' do
|
|
407
|
-
client = Watir::HttpClient.new
|
|
408
|
-
caps = Watir::Capabilities.new(:chrome,
|
|
409
|
-
url: 'https://example.com/wd/hub',
|
|
410
|
-
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
411
|
-
http_client: client)
|
|
412
|
-
args = []
|
|
413
|
-
expect {
|
|
414
435
|
args = caps.to_args
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
427
|
-
options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
|
|
428
|
-
caps = Watir::Capabilities.new(:chrome,
|
|
429
|
-
url: 'https://example.com/wd/hub',
|
|
430
|
-
proxy: proxy,
|
|
431
|
-
options: options,
|
|
432
|
-
http_client: client)
|
|
433
|
-
|
|
434
|
-
args = caps.to_args
|
|
435
|
-
expect(args.first).to eq :remote
|
|
436
|
-
expect(args.last[:http_client]).to eq client
|
|
437
|
-
actual_options = args.last[:options]
|
|
438
|
-
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
439
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
440
|
-
proxy = args.last[:options].proxy
|
|
441
|
-
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
442
|
-
expect(proxy.type).to eq(:manual)
|
|
443
|
-
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
444
|
-
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
445
|
-
end
|
|
446
|
-
|
|
447
|
-
it 'raises exception when both options & capabilities defined' do
|
|
448
|
-
options = {prefs: {foo: 'bar'}}
|
|
449
|
-
|
|
450
|
-
expect {
|
|
451
|
-
Watir::Capabilities.new(:chrome,
|
|
452
|
-
url: 'https://example.com/wd/hub',
|
|
453
|
-
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
454
|
-
options: options)
|
|
455
|
-
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
it 'allows headless to be set in chrome' do
|
|
459
|
-
capabilities = Watir::Capabilities.new(:chrome,
|
|
460
|
-
headless: true,
|
|
461
|
-
url: 'http://example.com')
|
|
462
|
-
args = capabilities.to_args
|
|
463
|
-
actual_options = args.last[:options]
|
|
464
|
-
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
465
|
-
end
|
|
466
|
-
|
|
467
|
-
it 'allows headless to be set in firefox' do
|
|
468
|
-
capabilities = Watir::Capabilities.new(:firefox,
|
|
469
|
-
headless: true,
|
|
470
|
-
url: 'http://example.com')
|
|
471
|
-
args = capabilities.to_args
|
|
472
|
-
|
|
473
|
-
expect(args.last[:options].args).to include '-headless'
|
|
474
|
-
end
|
|
436
|
+
expect(args.first).to eq :remote
|
|
437
|
+
expect(args.last[:http_client]).to eq client
|
|
438
|
+
actual_options = args.last[:options]
|
|
439
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
440
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
441
|
+
proxy = args.last[:options].proxy
|
|
442
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
443
|
+
expect(proxy.type).to eq(:manual)
|
|
444
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
445
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
446
|
+
end
|
|
475
447
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
|
479
|
-
other_options = {'other:options': {foo: 'bar'}}
|
|
448
|
+
it 'raises exception when both options & capabilities defined' do
|
|
449
|
+
options = {prefs: {foo: 'bar'}}
|
|
480
450
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
451
|
+
expect {
|
|
452
|
+
described_class.new(:chrome,
|
|
453
|
+
url: 'https://example.com/wd/hub',
|
|
454
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
|
455
|
+
options: options)
|
|
456
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
457
|
+
end
|
|
484
458
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
459
|
+
it 'allows headless to be set in chrome' do
|
|
460
|
+
capabilities = described_class.new(:chrome,
|
|
461
|
+
headless: true,
|
|
462
|
+
url: 'http://example.com')
|
|
463
|
+
args = capabilities.to_args
|
|
464
|
+
actual_options = args.last[:options]
|
|
465
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
466
|
+
end
|
|
492
467
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
499
|
-
expect(args.last).not_to include(:service)
|
|
500
|
-
end
|
|
468
|
+
it 'allows headless to be set in firefox' do
|
|
469
|
+
capabilities = described_class.new(:firefox,
|
|
470
|
+
headless: true,
|
|
471
|
+
url: 'http://example.com')
|
|
472
|
+
args = capabilities.to_args
|
|
501
473
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
args = capabilities.to_args
|
|
505
|
-
actual_options = args.last[:options]
|
|
506
|
-
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
507
|
-
end
|
|
474
|
+
expect(args.last[:options].args).to include '-headless'
|
|
475
|
+
end
|
|
508
476
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
477
|
+
it 'supports multiple vendor capabilities' do
|
|
478
|
+
sauce_options = {'sauce:options': {username: ENV.fetch('SAUCE_USERNAME', nil),
|
|
479
|
+
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
|
480
|
+
other_options = {'other:options': {foo: 'bar'}}
|
|
481
|
+
|
|
482
|
+
capabilities = described_class.new(:chrome,
|
|
483
|
+
options: sauce_options.merge(other_options),
|
|
484
|
+
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
485
|
+
|
|
486
|
+
generated_options = capabilities.to_args.last[:options]
|
|
487
|
+
expect(generated_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
488
|
+
expect(generated_options.unhandled_prompt_behavior).to eq :ignore
|
|
489
|
+
actual_options = generated_options.instance_variable_get(:@options)
|
|
490
|
+
expect(actual_options[:'sauce:options']).to eq sauce_options[:'sauce:options']
|
|
491
|
+
expect(actual_options[:'other:options']).to eq other_options[:'other:options']
|
|
492
|
+
end
|
|
516
493
|
end
|
|
517
494
|
|
|
518
|
-
|
|
519
|
-
options
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
end
|
|
495
|
+
describe 'chrome' do
|
|
496
|
+
it 'by default uses chrome, has client, options, but not capabilities' do
|
|
497
|
+
capabilities = described_class.new
|
|
498
|
+
args = capabilities.to_args
|
|
499
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
500
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
501
|
+
expect(args.last).not_to include(:service)
|
|
502
|
+
end
|
|
527
503
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
535
|
-
end
|
|
504
|
+
it 'sets headless by creating options' do
|
|
505
|
+
capabilities = described_class.new(:chrome, headless: true)
|
|
506
|
+
args = capabilities.to_args
|
|
507
|
+
actual_options = args.last[:options]
|
|
508
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
509
|
+
end
|
|
536
510
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
546
|
-
end
|
|
547
|
-
end
|
|
511
|
+
it 'sets headless in existing options class' do
|
|
512
|
+
capabilities = described_class.new(:chrome,
|
|
513
|
+
options: Selenium::WebDriver::Chrome::Options.new,
|
|
514
|
+
headless: true)
|
|
515
|
+
args = capabilities.to_args
|
|
516
|
+
actual_options = args.last[:options]
|
|
517
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
518
|
+
end
|
|
548
519
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
520
|
+
it 'sets headless when existing options is a Hash' do
|
|
521
|
+
options = {args: ['--foo']}
|
|
522
|
+
capabilities = described_class.new(:chrome,
|
|
523
|
+
options: options,
|
|
524
|
+
headless: true)
|
|
525
|
+
args = capabilities.to_args
|
|
526
|
+
actual_options = args.last[:options]
|
|
527
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
|
|
528
|
+
end
|
|
553
529
|
|
|
554
|
-
|
|
530
|
+
it 'generates options from Hash' do
|
|
531
|
+
options = {args: %w[--foo --bar]}
|
|
532
|
+
capabilities = described_class.new(:chrome, options: options)
|
|
533
|
+
args = capabilities.to_args
|
|
534
|
+
actual_options = args.last[:options]
|
|
535
|
+
expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
|
|
536
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
537
|
+
end
|
|
555
538
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
540
|
+
opts = {page_load_strategy: 'eager',
|
|
541
|
+
args: %w[--foo --bar]}
|
|
542
|
+
capabilities = described_class.new(:chrome,
|
|
543
|
+
options: opts)
|
|
544
|
+
args = capabilities.to_args
|
|
545
|
+
actual_options = args.last[:options]
|
|
546
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
547
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
548
|
+
end
|
|
559
549
|
end
|
|
560
550
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
551
|
+
describe 'firefox' do
|
|
552
|
+
it 'puts Profile inside Options as Hash' do
|
|
553
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
554
|
+
options = {args: ['--foo'], profile: profile}
|
|
564
555
|
|
|
565
|
-
|
|
556
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
566
557
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
558
|
+
actual_options = capabilities.to_args.last[:options]
|
|
559
|
+
expect(actual_options.args).to include '--foo'
|
|
560
|
+
expect(actual_options.profile).to eq profile
|
|
561
|
+
end
|
|
571
562
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
563
|
+
it 'sets headless by creating options' do
|
|
564
|
+
capabilities = described_class.new(:firefox, headless: true)
|
|
565
|
+
args = capabilities.to_args
|
|
566
|
+
actual_options = args.last[:options]
|
|
567
|
+
expect(actual_options.args).to include '-headless'
|
|
568
|
+
end
|
|
578
569
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
570
|
+
it 'sets headless in existing options class' do
|
|
571
|
+
capabilities = described_class.new(:firefox,
|
|
572
|
+
options: Selenium::WebDriver::Firefox::Options.new,
|
|
573
|
+
headless: true)
|
|
574
|
+
args = capabilities.to_args
|
|
575
|
+
actual_options = args.last[:options]
|
|
576
|
+
expect(actual_options.args).to include '-headless'
|
|
577
|
+
end
|
|
587
578
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
579
|
+
it 'sets headless when existing options is a Hash' do
|
|
580
|
+
options = {args: ['-foo']}
|
|
581
|
+
capabilities = described_class.new(:firefox,
|
|
582
|
+
options: options,
|
|
583
|
+
headless: true)
|
|
584
|
+
args = capabilities.to_args
|
|
585
|
+
actual_options = args.last[:options]
|
|
586
|
+
expect(actual_options.args).to include '-headless', '-foo'
|
|
587
|
+
end
|
|
597
588
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
589
|
+
it 'generates Options instance from Hash' do
|
|
590
|
+
options = {args: %w[--foo --bar]}
|
|
591
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
592
|
+
args = capabilities.to_args
|
|
593
|
+
actual_options = args.last[:options]
|
|
594
|
+
expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
|
|
595
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
596
|
+
end
|
|
606
597
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
598
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
599
|
+
opts = {page_load_strategy: 'eager',
|
|
600
|
+
args: %w[--foo --bar]}
|
|
601
|
+
capabilities = described_class.new(:firefox,
|
|
602
|
+
options: opts)
|
|
603
|
+
args = capabilities.to_args
|
|
604
|
+
actual_options = args.last[:options]
|
|
605
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
606
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
607
|
+
end
|
|
616
608
|
end
|
|
617
|
-
end
|
|
618
609
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
610
|
+
describe 'safari' do
|
|
611
|
+
it 'sets Technology Preview' do
|
|
612
|
+
halt_service(:safari)
|
|
622
613
|
|
|
623
|
-
|
|
614
|
+
described_class.new(:safari, technology_preview: true).to_args
|
|
624
615
|
|
|
625
|
-
|
|
626
|
-
|
|
616
|
+
expect(Selenium::WebDriver::Safari.technology_preview?).to be true
|
|
617
|
+
end
|
|
627
618
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
619
|
+
it 'generates options from Hash' do
|
|
620
|
+
options = {automatic_inspection: true}
|
|
621
|
+
capabilities = described_class.new(:safari, options: options)
|
|
622
|
+
args = capabilities.to_args
|
|
623
|
+
actual_options = args.last[:options]
|
|
624
|
+
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
|
625
|
+
expect(actual_options.automatic_inspection).to be true
|
|
626
|
+
end
|
|
636
627
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
628
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
629
|
+
opts = {page_load_strategy: 'eager',
|
|
630
|
+
automatic_inspection: true}
|
|
631
|
+
capabilities = described_class.new(:safari,
|
|
632
|
+
options: opts)
|
|
633
|
+
args = capabilities.to_args
|
|
634
|
+
actual_options = args.last[:options]
|
|
635
|
+
expect(actual_options.automatic_inspection).to be true
|
|
636
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
637
|
+
end
|
|
646
638
|
end
|
|
647
|
-
end
|
|
648
639
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
640
|
+
describe 'ie' do
|
|
641
|
+
it 'generates Options instance from Hash with args' do
|
|
642
|
+
options = {args: %w[--foo --bar]}
|
|
643
|
+
capabilities = described_class.new(:ie, options: options)
|
|
644
|
+
args = capabilities.to_args
|
|
645
|
+
actual_options = args.last[:options]
|
|
646
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
647
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
648
|
+
end
|
|
658
649
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
650
|
+
it 'generates Options instance from Hash with valid option' do
|
|
651
|
+
options = {browser_attach_timeout: true}
|
|
652
|
+
capabilities = described_class.new(:ie, options: options)
|
|
653
|
+
args = capabilities.to_args
|
|
654
|
+
actual_options = args.last[:options]
|
|
655
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
656
|
+
expect(actual_options.options[:browser_attach_timeout]).to be true
|
|
657
|
+
end
|
|
667
658
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
659
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
660
|
+
opts = {page_load_strategy: 'eager',
|
|
661
|
+
args: ['--foo']}
|
|
662
|
+
capabilities = described_class.new(:ie,
|
|
663
|
+
options: opts)
|
|
664
|
+
args = capabilities.to_args
|
|
665
|
+
actual_options = args.last[:options]
|
|
666
|
+
expect(actual_options.args).to include '--foo'
|
|
667
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
668
|
+
end
|
|
677
669
|
end
|
|
678
670
|
end
|
|
679
671
|
end
|