watir 7.2.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +9 -1
- data/.github/workflows/edge.yml +10 -2
- data/.github/workflows/firefox.yml +10 -2
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +3 -3
- data/.rubocop.yml +36 -14
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +17 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +2 -12
- data/lib/watir/cookies.rb +7 -2
- data/lib/watir/elements/date_field.rb +2 -2
- data/lib/watir/elements/date_time_field.rb +2 -2
- data/lib/watir/elements/select.rb +3 -3
- 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/element/selector_builder.rb +1 -1
- data/lib/watir/locators/text_field/matcher.rb +1 -5
- data/lib/watir/version.rb +1 -1
- data/lib/watir.rb +1 -0
- data/lib/watirspec/implementation.rb +1 -1
- data/lib/watirspec.rb +1 -1
- data/spec/locator_spec_helper.rb +3 -15
- data/spec/unit/capabilities_spec.rb +552 -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 +632 -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 +411 -409
- data/spec/watirspec/capabilities_spec.rb +99 -112
- data/spec/watirspec/cookies_spec.rb +144 -115
- 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 +202 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +216 -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 +88 -83
- data/spec/watirspec/support/rspec_matchers.rb +34 -25
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +423 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +6 -5
- metadata +47 -37
- 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
- data/support/travis.sh +0 -15
|
@@ -2,678 +2,669 @@
|
|
|
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
|
-
url: 'https://example.com/wd/hub/')
|
|
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_messages(file?: true, executable?: true)
|
|
35
|
+
service_class(browser).driver_path = nil
|
|
64
36
|
end
|
|
65
37
|
|
|
66
|
-
|
|
67
|
-
capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)
|
|
38
|
+
supported_browsers = %i[chrome edge firefox ie safari]
|
|
68
39
|
|
|
69
|
-
|
|
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)
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
48
|
+
supported_browsers.each do |browser_symbol|
|
|
49
|
+
it 'just browser has client & options not service' do
|
|
50
|
+
capabilities = described_class.new(browser_symbol)
|
|
75
51
|
|
|
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
52
|
args = capabilities.to_args
|
|
82
|
-
|
|
53
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
54
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
55
|
+
expect(args.last).not_to include(:service)
|
|
56
|
+
end
|
|
83
57
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
58
|
+
it 'errors with url and service' do
|
|
59
|
+
expect {
|
|
60
|
+
described_class.new(browser_symbol,
|
|
61
|
+
service: instance_double(Selenium::WebDriver::Service),
|
|
62
|
+
url: 'https://example.com/wd/hub/')
|
|
63
|
+
}.to raise_exception(ArgumentError, ':url and :service are not both allowed')
|
|
64
|
+
end
|
|
89
65
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
halt_service(browser_symbol)
|
|
66
|
+
it 'just options has client & options but not capabilities or service' do
|
|
67
|
+
capabilities = described_class.new(options: options_class(browser_symbol).new)
|
|
93
68
|
|
|
94
|
-
service = service_class(browser_symbol).new(port: 1234)
|
|
95
|
-
capabilities = Watir::Capabilities.new(browser_symbol, service: service)
|
|
96
69
|
args = capabilities.to_args
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(
|
|
70
|
+
|
|
71
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
72
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
73
|
+
expect(args.last).not_to include(:service)
|
|
100
74
|
end
|
|
101
75
|
|
|
102
|
-
it '
|
|
103
|
-
|
|
76
|
+
it 'just capabilities has client & capabilities but not service' do
|
|
77
|
+
caps = Selenium::WebDriver::Remote::Capabilities.new(browser_name: expected_browser(browser_symbol))
|
|
78
|
+
capabilities = described_class.new(capabilities: caps)
|
|
79
|
+
args = []
|
|
80
|
+
expect {
|
|
81
|
+
args = capabilities.to_args
|
|
82
|
+
}.to have_deprecated(:capabilities)
|
|
104
83
|
|
|
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'
|
|
84
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
85
|
+
expect(args.last[:capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
86
|
+
expect(args.last[:capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
87
|
+
expect(args.last).not_to include(:service)
|
|
113
88
|
end
|
|
114
89
|
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
describe 'service' do
|
|
91
|
+
it 'uses provided service' do
|
|
92
|
+
halt_service(browser_symbol)
|
|
93
|
+
|
|
94
|
+
service = service_class(browser_symbol).new(port: 1234)
|
|
95
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
96
|
+
args = capabilities.to_args
|
|
97
|
+
expect(args.first).to eq browser_symbol
|
|
98
|
+
actual_service = args.last[:service]
|
|
99
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'builds service from a Hash' do
|
|
103
|
+
halt_service(browser_symbol)
|
|
104
|
+
|
|
105
|
+
service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}
|
|
106
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
107
|
+
args = capabilities.to_args
|
|
108
|
+
expect(args.first).to eq browser_symbol
|
|
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(:@args)).to include '--foo', '--bar'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'is a bad argument to service' do
|
|
116
|
+
capabilities = described_class.new(browser_symbol, service: 7)
|
|
117
|
+
|
|
118
|
+
expect { capabilities.to_args }.to raise_exception(TypeError)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
describe 'http_client' do
|
|
123
|
+
it 'uses default HTTP Client' do
|
|
124
|
+
capabilities = described_class.new(browser_symbol)
|
|
125
|
+
args = capabilities.to_args
|
|
126
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'accepts an HTTP Client object' do
|
|
130
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
131
|
+
capabilities = described_class.new(browser_symbol, http_client: client)
|
|
132
|
+
args = capabilities.to_args
|
|
133
|
+
expect(args.last[:http_client]).to eq client
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'builds an HTTP Client from Hash' do
|
|
137
|
+
client_opts = {open_timeout: 10, read_timeout: 10}
|
|
138
|
+
capabilities = described_class.new(browser_symbol, http_client: client_opts)
|
|
139
|
+
args = capabilities.to_args
|
|
140
|
+
actual_client = args.last[:http_client]
|
|
141
|
+
expect(actual_client).to be_a HttpClient
|
|
142
|
+
expect(actual_client.instance_variable_get(:@read_timeout)).to eq 10
|
|
143
|
+
expect(actual_client.instance_variable_get(:@open_timeout)).to eq 10
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'raises an exception if :client receives something other than Hash or Client object' do
|
|
147
|
+
expect {
|
|
148
|
+
described_class.new(browser_symbol, http_client: 7).to_args
|
|
149
|
+
}.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')
|
|
150
|
+
end
|
|
119
151
|
end
|
|
120
|
-
end
|
|
121
152
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
capabilities =
|
|
153
|
+
it 'uses a listener' do
|
|
154
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
155
|
+
capabilities = described_class.new(browser_symbol, listener: listener)
|
|
125
156
|
args = capabilities.to_args
|
|
126
|
-
expect(args.last[:
|
|
157
|
+
expect(args.last[:listener]).to eq listener
|
|
127
158
|
end
|
|
128
159
|
|
|
129
|
-
it 'accepts
|
|
130
|
-
|
|
131
|
-
|
|
160
|
+
it 'accepts both capabilities and Options' do
|
|
161
|
+
caps = Selenium::WebDriver::Remote::Capabilities.new(browser_name: expected_browser(browser_symbol))
|
|
162
|
+
opts = options_class(browser_symbol).new
|
|
163
|
+
|
|
164
|
+
expect {
|
|
165
|
+
described_class.new(browser_symbol, capabilities: caps, options: opts)
|
|
166
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe 'timeout options' do
|
|
170
|
+
it 'accepts page load and script timeouts in seconds' do
|
|
171
|
+
options = {page_load_timeout: 11,
|
|
172
|
+
script_timeout: 12}
|
|
173
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
174
|
+
args = capabilities.to_args
|
|
175
|
+
actual_options = args.last[:options]
|
|
176
|
+
expect(actual_options.timeouts[:page_load]).to eq 11_000
|
|
177
|
+
expect(actual_options.timeouts[:script]).to eq 12_000
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'has deprecated timeouts key with page load warning' do
|
|
181
|
+
options = {timeouts: {page_load: 11}}
|
|
182
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
183
|
+
expect {
|
|
184
|
+
capabilities.to_args
|
|
185
|
+
}.to have_deprecated(:timeouts)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'has deprecated timeouts key with script warning' do
|
|
189
|
+
options = {timeouts: {script: 11}}
|
|
190
|
+
expect {
|
|
191
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
192
|
+
capabilities.to_args
|
|
193
|
+
}.to have_deprecated(:timeouts)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'does not allow implicit wait timeout in timeouts hash' do
|
|
197
|
+
options = {timeouts: {implicit: 1}}
|
|
198
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
199
|
+
expect {
|
|
200
|
+
capabilities.to_args
|
|
201
|
+
}.to raise_exception(ArgumentError, 'do not set implicit wait, Watir handles waiting automatically')
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'unhandled prompt behavior defaults to ignore' do
|
|
206
|
+
capabilities = described_class.new(browser_symbol)
|
|
132
207
|
args = capabilities.to_args
|
|
133
|
-
|
|
208
|
+
actual_options = args.last[:options]
|
|
209
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :ignore
|
|
134
210
|
end
|
|
135
211
|
|
|
136
|
-
it '
|
|
137
|
-
|
|
138
|
-
capabilities = Watir::Capabilities.new(browser_symbol, http_client: client_opts)
|
|
212
|
+
it 'unhandled prompt behavior can be overridden' do
|
|
213
|
+
capabilities = described_class.new(browser_symbol, options: {unhandled_prompt_behavior: :accept_and_notify})
|
|
139
214
|
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
|
|
215
|
+
actual_options = args.last[:options]
|
|
216
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
|
|
144
217
|
end
|
|
145
218
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
219
|
+
describe 'proxy' do
|
|
220
|
+
it 'adds Selenium Proxy to empty Options' do
|
|
221
|
+
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
222
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
223
|
+
args = capabilities.to_args
|
|
224
|
+
proxy = args.last[:options].proxy
|
|
225
|
+
|
|
226
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
227
|
+
expect(proxy.type).to eq(:manual)
|
|
228
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
229
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'builds a Proxy from Hash for Options' do
|
|
233
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
234
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
235
|
+
args = capabilities.to_args
|
|
236
|
+
proxy = args.last[:options].proxy
|
|
237
|
+
|
|
238
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
239
|
+
expect(proxy.type).to eq(:manual)
|
|
240
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
241
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it 'builds a Proxy from Hash and adds to Options' do
|
|
245
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
246
|
+
options = {unhandled_prompt_behavior: :accept,
|
|
247
|
+
page_load_strategy: :eager}
|
|
248
|
+
|
|
249
|
+
capabilities = described_class.new(browser_symbol, options: options, proxy: proxy)
|
|
250
|
+
args = capabilities.to_args
|
|
251
|
+
actual_options = args.last[:options]
|
|
252
|
+
|
|
253
|
+
expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
|
|
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
|
|
259
|
+
end
|
|
150
260
|
end
|
|
151
|
-
end
|
|
152
261
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
args = capabilities.to_args
|
|
157
|
-
expect(args.last[:listener]).to eq listener
|
|
158
|
-
end
|
|
262
|
+
it 'errors on bad proxy key' do
|
|
263
|
+
proxy = {bad_key: 'foo'}
|
|
264
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
159
265
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
opts = options_class(browser_symbol).new
|
|
266
|
+
expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
|
|
267
|
+
end
|
|
163
268
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
269
|
+
it 'errors on bad proxy object' do
|
|
270
|
+
capabilities = described_class.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
|
|
167
275
|
end
|
|
168
276
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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 = described_class.new(url: 'http://example.com')
|
|
174
289
|
args = capabilities.to_args
|
|
290
|
+
expect(args.first).to eq :remote
|
|
175
291
|
actual_options = args.last[:options]
|
|
176
|
-
expect(actual_options.
|
|
177
|
-
expect(actual_options.timeouts[:script]).to eq 12_000
|
|
292
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
178
293
|
end
|
|
179
294
|
|
|
180
|
-
it 'has
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
295
|
+
it 'just url & browser name has capabilities and client but not service' do
|
|
296
|
+
capabilities = described_class.new(:firefox,
|
|
297
|
+
url: 'https://example.com/wd/hub/')
|
|
298
|
+
args = capabilities.to_args
|
|
299
|
+
expect(args.first).to eq :remote
|
|
300
|
+
expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
|
|
301
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
187
302
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
expect {
|
|
191
|
-
capabilities = Watir::Capabilities.new(browser_symbol, options: options)
|
|
192
|
-
capabilities.to_args
|
|
193
|
-
}.to have_deprecated(:timeouts)
|
|
303
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options
|
|
304
|
+
expect(args.last).not_to include(:service)
|
|
194
305
|
end
|
|
195
306
|
|
|
196
|
-
it '
|
|
197
|
-
|
|
198
|
-
capabilities =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
307
|
+
it 'accepts a listener' do
|
|
308
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
309
|
+
capabilities = described_class.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
|
|
202
314
|
end
|
|
203
|
-
end
|
|
204
315
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
316
|
+
it 'accepts http client object' do
|
|
317
|
+
client = HttpClient.new
|
|
318
|
+
capabilities = described_class.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
|
|
211
327
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
328
|
+
it 'accepts http client Hash' do
|
|
329
|
+
capabilities = described_class.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
|
|
218
338
|
|
|
219
|
-
|
|
220
|
-
it 'adds Selenium Proxy to empty Options' do
|
|
339
|
+
it 'accepts proxy object' do
|
|
221
340
|
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
222
|
-
capabilities =
|
|
341
|
+
capabilities = described_class.new(:chrome,
|
|
342
|
+
url: 'https://example.com/wd/hub',
|
|
343
|
+
proxy: proxy)
|
|
223
344
|
args = capabilities.to_args
|
|
345
|
+
expect(args.first).to eq :remote
|
|
224
346
|
proxy = args.last[:options].proxy
|
|
225
|
-
|
|
226
347
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
227
348
|
expect(proxy.type).to eq(:manual)
|
|
228
349
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
229
350
|
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
230
351
|
end
|
|
231
352
|
|
|
232
|
-
it '
|
|
353
|
+
it 'accepts proxy Hash' do
|
|
233
354
|
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
234
|
-
capabilities =
|
|
355
|
+
capabilities = described_class.new(:chrome,
|
|
356
|
+
url: 'https://example.com/wd/hub',
|
|
357
|
+
proxy: proxy)
|
|
235
358
|
args = capabilities.to_args
|
|
359
|
+
expect(args.first).to eq :remote
|
|
236
360
|
proxy = args.last[:options].proxy
|
|
237
|
-
|
|
238
361
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
239
362
|
expect(proxy.type).to eq(:manual)
|
|
240
363
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
241
364
|
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
242
365
|
end
|
|
243
366
|
|
|
244
|
-
it '
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
capabilities = Watir::Capabilities.new(browser_symbol, options: options, proxy: proxy)
|
|
367
|
+
it 'accepts options object' do
|
|
368
|
+
capabilities = described_class.new(:chrome,
|
|
369
|
+
url: 'https://example.com/wd/hub',
|
|
370
|
+
options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
|
|
250
371
|
args = capabilities.to_args
|
|
372
|
+
expect(args.first).to eq :remote
|
|
251
373
|
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
|
|
374
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
375
|
+
expect(actual_options.args).to include('--foo')
|
|
259
376
|
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
377
|
|
|
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
|
|
378
|
+
it 'accepts options hash' do
|
|
379
|
+
options = {prefs: {foo: 'bar'}}
|
|
380
|
+
capabilities = described_class.new(:chrome,
|
|
381
|
+
url: 'http://example.com',
|
|
382
|
+
options: options)
|
|
383
|
+
args = capabilities.to_args
|
|
384
|
+
expect(args.first).to eq :remote
|
|
385
|
+
expect(args.last[:url]).to eq 'http://example.com'
|
|
386
|
+
actual_options = args.last[:options]
|
|
387
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
388
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
389
|
+
end
|
|
352
390
|
|
|
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
|
|
391
|
+
it 'accepts capabilities object' do
|
|
392
|
+
caps = described_class.new(:chrome,
|
|
393
|
+
url: 'https://example.com/wd/hub',
|
|
394
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'))
|
|
395
|
+
args = []
|
|
396
|
+
expect {
|
|
397
|
+
args = caps.to_args
|
|
398
|
+
}.to have_deprecated(:capabilities)
|
|
366
399
|
|
|
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
|
|
400
|
+
expect(args.first).to eq :remote
|
|
401
|
+
actual_capabilities = args.last[:capabilities]
|
|
402
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
403
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
404
|
+
end
|
|
377
405
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
389
|
-
end
|
|
406
|
+
it 'accepts http client & capabilities objects' do
|
|
407
|
+
client = HttpClient.new
|
|
408
|
+
caps = described_class.new(:chrome,
|
|
409
|
+
url: 'https://example.com/wd/hub',
|
|
410
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'),
|
|
411
|
+
http_client: client)
|
|
412
|
+
args = []
|
|
413
|
+
expect {
|
|
414
|
+
args = caps.to_args
|
|
415
|
+
}.to have_deprecated(:capabilities)
|
|
390
416
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
args = caps.to_args
|
|
398
|
-
}.to have_deprecated(:capabilities)
|
|
417
|
+
expect(args.first).to eq :remote
|
|
418
|
+
expect(args.last[:http_client]).to eq client
|
|
419
|
+
actual_capabilities = args.last[:capabilities]
|
|
420
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
421
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
422
|
+
end
|
|
399
423
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
424
|
+
it 'accepts http client & proxy & options objects' do
|
|
425
|
+
client = HttpClient.new
|
|
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 = described_class.new(:chrome,
|
|
429
|
+
url: 'https://example.com/wd/hub',
|
|
430
|
+
proxy: proxy,
|
|
431
|
+
options: options,
|
|
432
|
+
http_client: client)
|
|
405
433
|
|
|
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
434
|
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
|
|
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
|
|
475
446
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
|
479
|
-
other_options = {'other:options': {foo: 'bar'}}
|
|
447
|
+
it 'raises exception when both options & capabilities defined' do
|
|
448
|
+
options = {prefs: {foo: 'bar'}}
|
|
480
449
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
450
|
+
expect {
|
|
451
|
+
described_class.new(:chrome,
|
|
452
|
+
url: 'https://example.com/wd/hub',
|
|
453
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'),
|
|
454
|
+
options: options)
|
|
455
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
456
|
+
end
|
|
484
457
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
458
|
+
it 'allows headless to be set in chrome' do
|
|
459
|
+
capabilities = described_class.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
|
|
492
466
|
|
|
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
|
|
467
|
+
it 'allows headless to be set in firefox' do
|
|
468
|
+
capabilities = described_class.new(:firefox,
|
|
469
|
+
headless: true,
|
|
470
|
+
url: 'http://example.com')
|
|
471
|
+
args = capabilities.to_args
|
|
501
472
|
|
|
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
|
|
473
|
+
expect(args.last[:options].args).to include '-headless'
|
|
474
|
+
end
|
|
508
475
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
476
|
+
it 'supports multiple vendor capabilities' do
|
|
477
|
+
sauce_options = {'sauce:options': {username: ENV.fetch('SAUCE_USERNAME', nil),
|
|
478
|
+
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
|
479
|
+
other_options = {'other:options': {foo: 'bar'}}
|
|
480
|
+
|
|
481
|
+
capabilities = described_class.new(:chrome,
|
|
482
|
+
options: sauce_options.merge(other_options),
|
|
483
|
+
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
484
|
+
|
|
485
|
+
generated_options = capabilities.to_args.last[:options]
|
|
486
|
+
expect(generated_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
487
|
+
expect(generated_options.unhandled_prompt_behavior).to eq :ignore
|
|
488
|
+
actual_options = generated_options.instance_variable_get(:@options)
|
|
489
|
+
expect(actual_options[:'sauce:options']).to eq sauce_options[:'sauce:options']
|
|
490
|
+
expect(actual_options[:'other:options']).to eq other_options[:'other:options']
|
|
491
|
+
end
|
|
516
492
|
end
|
|
517
493
|
|
|
518
|
-
|
|
519
|
-
options
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
end
|
|
494
|
+
describe 'chrome' do
|
|
495
|
+
it 'by default uses chrome, has client, options, but not capabilities' do
|
|
496
|
+
capabilities = described_class.new
|
|
497
|
+
args = capabilities.to_args
|
|
498
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
499
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
500
|
+
expect(args.last).not_to include(:service)
|
|
501
|
+
end
|
|
527
502
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
535
|
-
end
|
|
503
|
+
it 'sets headless by creating options' do
|
|
504
|
+
capabilities = described_class.new(:chrome, headless: true)
|
|
505
|
+
args = capabilities.to_args
|
|
506
|
+
actual_options = args.last[:options]
|
|
507
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
508
|
+
end
|
|
536
509
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
expect(actual_options.args).to include '--foo', '--bar'
|
|
546
|
-
end
|
|
547
|
-
end
|
|
510
|
+
it 'sets headless in existing options class' do
|
|
511
|
+
capabilities = described_class.new(:chrome,
|
|
512
|
+
options: Selenium::WebDriver::Chrome::Options.new,
|
|
513
|
+
headless: true)
|
|
514
|
+
args = capabilities.to_args
|
|
515
|
+
actual_options = args.last[:options]
|
|
516
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
517
|
+
end
|
|
548
518
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
519
|
+
it 'sets headless when existing options is a Hash' do
|
|
520
|
+
options = {args: ['--foo']}
|
|
521
|
+
capabilities = described_class.new(:chrome,
|
|
522
|
+
options: options,
|
|
523
|
+
headless: true)
|
|
524
|
+
args = capabilities.to_args
|
|
525
|
+
actual_options = args.last[:options]
|
|
526
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
|
|
527
|
+
end
|
|
553
528
|
|
|
554
|
-
|
|
529
|
+
it 'generates options from Hash' do
|
|
530
|
+
options = {args: %w[--foo --bar]}
|
|
531
|
+
capabilities = described_class.new(:chrome, options: options)
|
|
532
|
+
args = capabilities.to_args
|
|
533
|
+
actual_options = args.last[:options]
|
|
534
|
+
expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
|
|
535
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
536
|
+
end
|
|
555
537
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
538
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
539
|
+
opts = {page_load_strategy: 'eager',
|
|
540
|
+
args: %w[--foo --bar]}
|
|
541
|
+
capabilities = described_class.new(:chrome,
|
|
542
|
+
options: opts)
|
|
543
|
+
args = capabilities.to_args
|
|
544
|
+
actual_options = args.last[:options]
|
|
545
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
546
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
547
|
+
end
|
|
559
548
|
end
|
|
560
549
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
550
|
+
describe 'firefox' do
|
|
551
|
+
it 'puts Profile inside Options as Hash' do
|
|
552
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
553
|
+
options = {args: ['--foo'], profile: profile}
|
|
564
554
|
|
|
565
|
-
|
|
555
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
566
556
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
557
|
+
actual_options = capabilities.to_args.last[:options]
|
|
558
|
+
expect(actual_options.args).to include '--foo'
|
|
559
|
+
expect(actual_options.profile).to eq profile
|
|
560
|
+
end
|
|
571
561
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
562
|
+
it 'sets headless by creating options' do
|
|
563
|
+
capabilities = described_class.new(:firefox, headless: true)
|
|
564
|
+
args = capabilities.to_args
|
|
565
|
+
actual_options = args.last[:options]
|
|
566
|
+
expect(actual_options.args).to include '-headless'
|
|
567
|
+
end
|
|
578
568
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
569
|
+
it 'sets headless in existing options class' do
|
|
570
|
+
capabilities = described_class.new(:firefox,
|
|
571
|
+
options: Selenium::WebDriver::Firefox::Options.new,
|
|
572
|
+
headless: true)
|
|
573
|
+
args = capabilities.to_args
|
|
574
|
+
actual_options = args.last[:options]
|
|
575
|
+
expect(actual_options.args).to include '-headless'
|
|
576
|
+
end
|
|
587
577
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
578
|
+
it 'sets headless when existing options is a Hash' do
|
|
579
|
+
options = {args: ['-foo']}
|
|
580
|
+
capabilities = described_class.new(:firefox,
|
|
581
|
+
options: options,
|
|
582
|
+
headless: true)
|
|
583
|
+
args = capabilities.to_args
|
|
584
|
+
actual_options = args.last[:options]
|
|
585
|
+
expect(actual_options.args).to include '-headless', '-foo'
|
|
586
|
+
end
|
|
597
587
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
588
|
+
it 'generates Options instance from Hash' do
|
|
589
|
+
options = {args: %w[--foo --bar]}
|
|
590
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
591
|
+
args = capabilities.to_args
|
|
592
|
+
actual_options = args.last[:options]
|
|
593
|
+
expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
|
|
594
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
595
|
+
end
|
|
606
596
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
597
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
598
|
+
opts = {page_load_strategy: 'eager',
|
|
599
|
+
args: %w[--foo --bar]}
|
|
600
|
+
capabilities = described_class.new(:firefox,
|
|
601
|
+
options: opts)
|
|
602
|
+
args = capabilities.to_args
|
|
603
|
+
actual_options = args.last[:options]
|
|
604
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
605
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
606
|
+
end
|
|
616
607
|
end
|
|
617
|
-
end
|
|
618
608
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
609
|
+
describe 'safari' do
|
|
610
|
+
it 'sets Technology Preview' do
|
|
611
|
+
halt_service(:safari)
|
|
622
612
|
|
|
623
|
-
|
|
613
|
+
described_class.new(:safari, technology_preview: true).to_args
|
|
624
614
|
|
|
625
|
-
|
|
626
|
-
|
|
615
|
+
expect(Selenium::WebDriver::Safari.technology_preview?).to be true
|
|
616
|
+
end
|
|
627
617
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
618
|
+
it 'generates options from Hash' do
|
|
619
|
+
options = {automatic_inspection: true}
|
|
620
|
+
capabilities = described_class.new(:safari, options: options)
|
|
621
|
+
args = capabilities.to_args
|
|
622
|
+
actual_options = args.last[:options]
|
|
623
|
+
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
|
624
|
+
expect(actual_options.automatic_inspection).to be true
|
|
625
|
+
end
|
|
636
626
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
627
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
628
|
+
opts = {page_load_strategy: 'eager',
|
|
629
|
+
automatic_inspection: true}
|
|
630
|
+
capabilities = described_class.new(:safari,
|
|
631
|
+
options: opts)
|
|
632
|
+
args = capabilities.to_args
|
|
633
|
+
actual_options = args.last[:options]
|
|
634
|
+
expect(actual_options.automatic_inspection).to be true
|
|
635
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
636
|
+
end
|
|
646
637
|
end
|
|
647
|
-
end
|
|
648
638
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
639
|
+
describe 'ie' do
|
|
640
|
+
it 'generates Options instance from Hash with args' do
|
|
641
|
+
options = {args: %w[--foo --bar]}
|
|
642
|
+
capabilities = described_class.new(:ie, options: options)
|
|
643
|
+
args = capabilities.to_args
|
|
644
|
+
actual_options = args.last[:options]
|
|
645
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
646
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
647
|
+
end
|
|
658
648
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
649
|
+
it 'generates Options instance from Hash with valid option' do
|
|
650
|
+
options = {browser_attach_timeout: true}
|
|
651
|
+
capabilities = described_class.new(:ie, options: options)
|
|
652
|
+
args = capabilities.to_args
|
|
653
|
+
actual_options = args.last[:options]
|
|
654
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
655
|
+
expect(actual_options.options[:browser_attach_timeout]).to be true
|
|
656
|
+
end
|
|
667
657
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
658
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
659
|
+
opts = {page_load_strategy: 'eager',
|
|
660
|
+
args: ['--foo']}
|
|
661
|
+
capabilities = described_class.new(:ie,
|
|
662
|
+
options: opts)
|
|
663
|
+
args = capabilities.to_args
|
|
664
|
+
actual_options = args.last[:options]
|
|
665
|
+
expect(actual_options.args).to include '--foo'
|
|
666
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
667
|
+
end
|
|
677
668
|
end
|
|
678
669
|
end
|
|
679
670
|
end
|