sauce_bindings 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/lib/sauce_bindings.rb +7 -0
- data/lib/sauce_bindings/base_configurations.rb +9 -0
- data/lib/sauce_bindings/chrome_configurations.rb +9 -0
- data/lib/sauce_bindings/edge_configurations.rb +9 -0
- data/lib/sauce_bindings/firefox_configurations.rb +9 -0
- data/lib/sauce_bindings/ie_configurations.rb +9 -0
- data/lib/sauce_bindings/options.rb +117 -47
- data/lib/sauce_bindings/safari_configurations.rb +9 -0
- data/lib/sauce_bindings/session.rb +1 -1
- data/lib/sauce_bindings/vdc_configurations.rb +13 -0
- data/lib/sauce_bindings/version.rb +1 -1
- data/sauce_bindings.gemspec +4 -3
- data/spec/deprecated_options.yml +56 -0
- data/spec/examples/basic_options_spec.rb +1 -3
- data/spec/examples/browser_options_spec.rb +0 -2
- data/spec/examples/create_session_spec.rb +0 -2
- data/spec/examples/data_center_spec.rb +0 -2
- data/spec/examples/sauce_options_spec.rb +0 -2
- data/spec/integration/desktop_spec.rb +10 -15
- data/spec/options.yml +4 -8
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/capybara_session_spec.rb +8 -4
- data/spec/unit/deprecated_options_spec.rb +472 -0
- data/spec/unit/options_spec.rb +339 -210
- data/spec/unit/session_spec.rb +10 -6
- metadata +19 -14
@@ -4,11 +4,9 @@ require 'sauce_bindings'
|
|
4
4
|
require 'rspec'
|
5
5
|
|
6
6
|
describe 'Basic Options' do
|
7
|
-
before { WebMock.allow_net_connect! }
|
8
|
-
|
9
7
|
it 'creates session' do
|
10
8
|
# 1. Create a SauceOptions instance with the 3 primary parameters
|
11
|
-
sauce_options = SauceBindings::Options.firefox(browser_version: '
|
9
|
+
sauce_options = SauceBindings::Options.firefox(browser_version: '88.0',
|
12
10
|
platform_name: 'Windows 8')
|
13
11
|
|
14
12
|
# 2. Create Session object with SauceOptions object instance
|
@@ -4,8 +4,6 @@ require 'sauce_bindings'
|
|
4
4
|
require 'rspec'
|
5
5
|
|
6
6
|
describe 'Browser Options' do
|
7
|
-
before { WebMock.allow_net_connect! }
|
8
|
-
|
9
7
|
it 'creates session' do
|
10
8
|
# 1. Create Selenium Browser Options instance
|
11
9
|
browser_options = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
@@ -4,8 +4,6 @@ require 'sauce_bindings'
|
|
4
4
|
require 'rspec'
|
5
5
|
|
6
6
|
describe 'Sauce Options' do
|
7
|
-
before { WebMock.allow_net_connect! }
|
8
|
-
|
9
7
|
it 'creates session' do
|
10
8
|
# 1. Create a SauceOptions instance with Sauce Labs Specific Options
|
11
9
|
sauce_options = SauceBindings::Options.firefox(extended_debugging: true,
|
@@ -8,33 +8,28 @@ module SauceBindings
|
|
8
8
|
before { WebMock.allow_net_connect! }
|
9
9
|
|
10
10
|
it 'defaults to US West' do
|
11
|
-
session = Session.new
|
12
|
-
driver = session.start
|
11
|
+
@session = Session.new
|
12
|
+
driver = @session.start
|
13
13
|
|
14
14
|
expect(driver).not_to be_nil
|
15
|
-
expect(session.url).to include('us-west-1')
|
16
|
-
session.stop(true)
|
15
|
+
expect(@session.url).to include('us-west-1')
|
17
16
|
end
|
18
17
|
|
19
18
|
it 'executes on US East' do
|
20
|
-
options = Options.
|
21
|
-
session = Session.new(options, data_center: :US_EAST)
|
22
|
-
driver = session.start
|
19
|
+
options = Options.chrome(platform_name: 'Linux')
|
20
|
+
@session = Session.new(options, data_center: :US_EAST)
|
21
|
+
driver = @session.start
|
23
22
|
|
24
23
|
expect(driver).not_to be_nil
|
25
|
-
expect(session.url).to include('us-east-1')
|
26
|
-
|
27
|
-
session.stop(true)
|
24
|
+
expect(@session.url).to include('us-east-1')
|
28
25
|
end
|
29
26
|
|
30
27
|
it 'executes on EU Central' do
|
31
|
-
session = Session.new(data_center: :EU_CENTRAL)
|
32
|
-
driver = session.start
|
28
|
+
@session = Session.new(data_center: :EU_CENTRAL)
|
29
|
+
driver = @session.start
|
33
30
|
|
34
31
|
expect(driver).not_to be_nil
|
35
|
-
expect(session.url).to include('eu-central-1')
|
36
|
-
|
37
|
-
session.stop(true)
|
32
|
+
expect(@session.url).to include('eu-central-1')
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
data/spec/options.yml
CHANGED
@@ -7,21 +7,17 @@ example_values:
|
|
7
7
|
set_window_rect: true
|
8
8
|
unhandled_prompt_behavior: "accept"
|
9
9
|
strict_file_interactability: true
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
script: 29
|
14
|
-
avoid_proxy: true
|
10
|
+
implicit_wait_timeout: 1
|
11
|
+
page_load_timeout: 59
|
12
|
+
script_timeout: 29
|
15
13
|
build: 'Sample Build Name'
|
16
|
-
capture_performance: true
|
17
|
-
chromedriver_version: '71'
|
18
14
|
command_timeout: 2
|
19
15
|
custom_data:
|
20
16
|
foo: 'foo'
|
21
17
|
bar: 'bar'
|
22
18
|
extended_debugging: true
|
19
|
+
geckodriver_version: '0.23'
|
23
20
|
idle_timeout: 3
|
24
|
-
iedriver_version: '3.141.0'
|
25
21
|
max_duration: 300
|
26
22
|
name: 'Sample Test Name'
|
27
23
|
parent_tunnel: 'Mommy'
|
data/spec/spec_helper.rb
CHANGED
@@ -17,10 +17,14 @@ module SauceBindings
|
|
17
17
|
'sauce:options': {build: 'TEMP BUILD: 11'}}
|
18
18
|
end
|
19
19
|
|
20
|
-
def expect_request
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def expect_request
|
21
|
+
se3 = {desiredCapabilities: default_capabilities,
|
22
|
+
capabilities: {firstMatch: [default_capabilities]}}.to_json
|
23
|
+
se4 = {capabilities: {alwaysMatch: default_capabilities}}.to_json
|
24
|
+
|
25
|
+
body = Selenium::WebDriver::VERSION[0] == '3' ? se3 : se4
|
26
|
+
|
27
|
+
endpoint = 'https://ondemand.us-west-1.saucelabs.com/wd/hub/session'
|
24
28
|
stub_request(:post, endpoint).with(body: body).to_return(valid_response)
|
25
29
|
end
|
26
30
|
|
@@ -0,0 +1,472 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module SauceBindings
|
6
|
+
describe Options do
|
7
|
+
before do
|
8
|
+
allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
|
9
|
+
allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
|
10
|
+
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#new' do
|
14
|
+
let(:default_options) do
|
15
|
+
{'browserName' => 'chrome',
|
16
|
+
'browserVersion' => 'latest',
|
17
|
+
'platformName' => 'Windows 10',
|
18
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'}}
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'uses latest Chrome version on Windows 10 by default' do
|
22
|
+
options = Options.new
|
23
|
+
|
24
|
+
expect(options.browser_name).to eq 'chrome'
|
25
|
+
expect(options.browser_version).to eq 'latest'
|
26
|
+
expect(options.platform_name).to eq 'Windows 10'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'accepts provided values for browser, browser version and platform name' do
|
30
|
+
options = Options.new(browser_name: 'firefox',
|
31
|
+
browser_version: '123',
|
32
|
+
platform_name: 'Mac')
|
33
|
+
|
34
|
+
expect(options.browser_name).to eq 'firefox'
|
35
|
+
expect(options.browser_version).to eq '123'
|
36
|
+
expect(options.platform_name).to eq 'Mac'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'accepts other w3c values' do
|
40
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
41
|
+
timeouts = {implicit: 1,
|
42
|
+
page_load: 59,
|
43
|
+
script: 29}
|
44
|
+
options = Options.new(accept_insecure_certs: true,
|
45
|
+
page_load_strategy: 'eager',
|
46
|
+
proxy: proxy,
|
47
|
+
set_window_rect: true,
|
48
|
+
unhandled_prompt_behavior: 'accept',
|
49
|
+
strict_file_interactability: true,
|
50
|
+
timeouts: timeouts)
|
51
|
+
|
52
|
+
expect(options.accept_insecure_certs).to eq true
|
53
|
+
expect(options.page_load_strategy).to eq 'eager'
|
54
|
+
expect(options.proxy).to eq proxy
|
55
|
+
expect(options.set_window_rect).to eq true
|
56
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
57
|
+
expect(options.strict_file_interactability).to eq true
|
58
|
+
expect(options.timeouts).to eq timeouts
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'accepts Sauce Labs specific settings' do
|
62
|
+
custom_data = {foo: 'foo',
|
63
|
+
bar: 'bar'}
|
64
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
65
|
+
args: ['--silent', '-a', '-q'],
|
66
|
+
background: false,
|
67
|
+
timeout: 120}
|
68
|
+
tags = %w[foo bar foobar]
|
69
|
+
sauce_options = {
|
70
|
+
avoid_proxy: true,
|
71
|
+
build: 'Sample Build Name',
|
72
|
+
capture_performance: true,
|
73
|
+
chromedriver_version: '71',
|
74
|
+
command_timeout: 2,
|
75
|
+
custom_data: custom_data,
|
76
|
+
extended_debugging: true,
|
77
|
+
idle_timeout: 3,
|
78
|
+
iedriver_version: '3.141.0',
|
79
|
+
max_duration: 300,
|
80
|
+
name: 'Sample Test Name',
|
81
|
+
parent_tunnel: 'Mommy',
|
82
|
+
prerun: prerun,
|
83
|
+
priority: 0,
|
84
|
+
public: 'team',
|
85
|
+
record_logs: false,
|
86
|
+
record_screenshots: false,
|
87
|
+
record_video: false,
|
88
|
+
screen_resolution: '10x10',
|
89
|
+
selenium_version: '3.141.59',
|
90
|
+
tags: tags,
|
91
|
+
time_zone: 'San Francisco',
|
92
|
+
tunnel_identifier: 'tunnelname',
|
93
|
+
video_upload_on_pass: false
|
94
|
+
}
|
95
|
+
|
96
|
+
options = Options.new(**sauce_options)
|
97
|
+
|
98
|
+
expect(options.avoid_proxy).to eq true
|
99
|
+
expect(options.build).to eq 'Sample Build Name'
|
100
|
+
expect(options.capture_performance).to eq true
|
101
|
+
expect(options.chromedriver_version).to eq '71'
|
102
|
+
expect(options.command_timeout).to eq 2
|
103
|
+
expect(options.custom_data).to eq custom_data
|
104
|
+
expect(options.extended_debugging).to eq true
|
105
|
+
expect(options.idle_timeout).to eq 3
|
106
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
107
|
+
expect(options.max_duration).to eq 300
|
108
|
+
expect(options.name).to eq 'Sample Test Name'
|
109
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
110
|
+
expect(options.prerun).to eq prerun
|
111
|
+
expect(options.priority).to eq 0
|
112
|
+
expect(options.public).to eq 'team'
|
113
|
+
expect(options.record_logs).to eq false
|
114
|
+
expect(options.record_screenshots).to eq false
|
115
|
+
expect(options.record_video).to eq false
|
116
|
+
expect(options.screen_resolution).to eq '10x10'
|
117
|
+
expect(options.selenium_version).to eq '3.141.59'
|
118
|
+
expect(options.tags).to eq tags
|
119
|
+
expect(options.time_zone).to eq 'San Francisco'
|
120
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
121
|
+
expect(options.video_upload_on_pass).to eq false
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'accepts Selenium Capabilities and overrides default browser' do
|
125
|
+
caps = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true,
|
126
|
+
page_load_strategy: 'eager')
|
127
|
+
options = Options.new(selenium_options: caps)
|
128
|
+
|
129
|
+
expect(options.browser_name).to eq 'firefox'
|
130
|
+
expect(options.accept_insecure_certs).to eq true
|
131
|
+
expect(options.page_load_strategy).to eq 'eager'
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'accepts Selenium Options and overrides default browser' do
|
135
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
136
|
+
options = Options.new(selenium_options: browser_opts)
|
137
|
+
|
138
|
+
expect(options.browser_name).to eq 'firefox'
|
139
|
+
expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'accepts Selenium Capabilities and Options class instances' do
|
143
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
|
144
|
+
page_load_strategy: 'eager')
|
145
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
146
|
+
options = Options.new(selenium_options: [caps, browser_opts])
|
147
|
+
|
148
|
+
expect(options.page_load_strategy).to eq 'eager'
|
149
|
+
expect(options.accept_insecure_certs).to eq true
|
150
|
+
expect(options.selenium_options['goog:chromeOptions']).to eq('args' => ['--foo'])
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'accepts W3C, Sauce, Browser Options and Capabilities at the same time' do
|
154
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(page_load_strategy: 'eager')
|
155
|
+
browser_opts = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
156
|
+
|
157
|
+
options = Options.new(browser_version: '77',
|
158
|
+
accept_insecure_certs: true,
|
159
|
+
command_timeout: 2,
|
160
|
+
time_zone: 'Alaska',
|
161
|
+
selenium_options: [caps, browser_opts])
|
162
|
+
|
163
|
+
expect(options.browser_name).to eq 'firefox'
|
164
|
+
expect(options.browser_version).to eq '77'
|
165
|
+
expect(options.platform_name).to eq 'Windows 10'
|
166
|
+
expect(options.accept_insecure_certs).to eq true
|
167
|
+
expect(options.command_timeout).to eq 2
|
168
|
+
expect(options.time_zone).to eq 'Alaska'
|
169
|
+
expect(options.page_load_strategy).to eq 'eager'
|
170
|
+
|
171
|
+
expect(options.selenium_options['moz:firefoxOptions']).to eq('args' => ['--foo'])
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'creates a default build value' do
|
175
|
+
options = Options.new
|
176
|
+
expect(options.build).to eq 'TEMP BUILD: 11'
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'raises ArgumentError if parameter is not recognized as valid' do
|
180
|
+
expect { Options.new(foo: 'bar') }.to raise_exception(ArgumentError)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe '#accessors' do
|
185
|
+
it 'parses w3c values' do
|
186
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
187
|
+
timeouts = {implicit: 1,
|
188
|
+
page_load: 59,
|
189
|
+
script: 29}
|
190
|
+
|
191
|
+
options = Options.new
|
192
|
+
|
193
|
+
options.browser_name = 'firefox'
|
194
|
+
options.browser_version = '7'
|
195
|
+
options.platform_name = 'macOS 10.14'
|
196
|
+
options.accept_insecure_certs = true
|
197
|
+
options.page_load_strategy = 'eager'
|
198
|
+
options.proxy = proxy
|
199
|
+
options.set_window_rect = true
|
200
|
+
options.unhandled_prompt_behavior = 'accept'
|
201
|
+
options.strict_file_interactability = true
|
202
|
+
options.timeouts = timeouts
|
203
|
+
|
204
|
+
expect(options.browser_name).to eq 'firefox'
|
205
|
+
expect(options.browser_version).to eq '7'
|
206
|
+
expect(options.platform_name).to eq 'macOS 10.14'
|
207
|
+
expect(options.accept_insecure_certs).to eq true
|
208
|
+
expect(options.page_load_strategy).to eq 'eager'
|
209
|
+
expect(options.proxy).to eq proxy
|
210
|
+
expect(options.set_window_rect).to eq true
|
211
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
212
|
+
expect(options.strict_file_interactability).to eq true
|
213
|
+
expect(options.timeouts).to eq timeouts
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'parses Sauce values' do
|
217
|
+
custom_data = {foo: 'foo',
|
218
|
+
bar: 'bar'}
|
219
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
220
|
+
args: ['--silent', '-a', '-q'],
|
221
|
+
background: false,
|
222
|
+
timeout: 120}
|
223
|
+
tags = %w[foo bar foobar]
|
224
|
+
|
225
|
+
options = Options.new
|
226
|
+
|
227
|
+
options.avoid_proxy = true
|
228
|
+
options.build = 'Sample Build Name'
|
229
|
+
options.capture_performance = true
|
230
|
+
options.chromedriver_version = '71'
|
231
|
+
options.command_timeout = 2
|
232
|
+
options.custom_data = custom_data
|
233
|
+
options.extended_debugging = true
|
234
|
+
options.idle_timeout = 3
|
235
|
+
options.iedriver_version = '3.141.0'
|
236
|
+
options.max_duration = 300
|
237
|
+
options.name = 'Sample Test Name'
|
238
|
+
options.parent_tunnel = 'Mommy'
|
239
|
+
options.prerun = prerun
|
240
|
+
options.priority = 0
|
241
|
+
options.public = 'team'
|
242
|
+
options.record_logs = false
|
243
|
+
options.record_screenshots = false
|
244
|
+
options.record_video = false
|
245
|
+
options.screen_resolution = '10x10'
|
246
|
+
options.selenium_version = '3.141.59'
|
247
|
+
options.tags = tags
|
248
|
+
options.time_zone = 'San Francisco'
|
249
|
+
options.tunnel_identifier = 'tunnelname'
|
250
|
+
options.video_upload_on_pass = false
|
251
|
+
|
252
|
+
expect(options.avoid_proxy).to eq true
|
253
|
+
expect(options.build).to eq 'Sample Build Name'
|
254
|
+
expect(options.capture_performance).to eq true
|
255
|
+
expect(options.chromedriver_version).to eq '71'
|
256
|
+
expect(options.command_timeout).to eq 2
|
257
|
+
expect(options.custom_data).to eq custom_data
|
258
|
+
expect(options.extended_debugging).to eq true
|
259
|
+
expect(options.idle_timeout).to eq 3
|
260
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
261
|
+
expect(options.max_duration).to eq 300
|
262
|
+
expect(options.name).to eq 'Sample Test Name'
|
263
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
264
|
+
expect(options.prerun).to eq prerun
|
265
|
+
expect(options.priority).to eq 0
|
266
|
+
expect(options.public).to eq 'team'
|
267
|
+
expect(options.record_logs).to eq false
|
268
|
+
expect(options.record_screenshots).to eq false
|
269
|
+
expect(options.record_video).to eq false
|
270
|
+
expect(options.screen_resolution).to eq '10x10'
|
271
|
+
expect(options.selenium_version).to eq '3.141.59'
|
272
|
+
expect(options.tags).to eq tags
|
273
|
+
expect(options.time_zone).to eq 'San Francisco'
|
274
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
275
|
+
expect(options.video_upload_on_pass).to eq false
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
describe '#merge_capabilities' do
|
280
|
+
it 'loads options from configuration' do
|
281
|
+
timeouts = {implicit: 1,
|
282
|
+
page_load: 59,
|
283
|
+
script: 29}
|
284
|
+
custom_data = {foo: 'foo',
|
285
|
+
bar: 'bar'}
|
286
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
287
|
+
args: ['--silent', '-a', '-q'],
|
288
|
+
background: false,
|
289
|
+
timeout: 120}
|
290
|
+
tags = %w[foo bar foobar]
|
291
|
+
|
292
|
+
options = Options.new
|
293
|
+
yaml = YAML.load_file('spec/deprecated_options.yml')
|
294
|
+
options.merge_capabilities(yaml['example_values'])
|
295
|
+
|
296
|
+
expect(options.browser_name).to eq 'firefox'
|
297
|
+
expect(options.browser_version).to eq '123'
|
298
|
+
expect(options.platform_name).to eq 'Mac'
|
299
|
+
expect(options.accept_insecure_certs).to eq true
|
300
|
+
expect(options.page_load_strategy).to eq 'eager'
|
301
|
+
expect(options.set_window_rect).to eq true
|
302
|
+
expect(options.unhandled_prompt_behavior).to eq 'accept'
|
303
|
+
expect(options.strict_file_interactability).to eq true
|
304
|
+
expect(options.timeouts).to eq timeouts
|
305
|
+
expect(options.avoid_proxy).to eq true
|
306
|
+
expect(options.build).to eq 'Sample Build Name'
|
307
|
+
expect(options.capture_performance).to eq true
|
308
|
+
expect(options.chromedriver_version).to eq '71'
|
309
|
+
expect(options.command_timeout).to eq 2
|
310
|
+
expect(options.custom_data).to eq custom_data
|
311
|
+
expect(options.extended_debugging).to eq true
|
312
|
+
expect(options.idle_timeout).to eq 3
|
313
|
+
expect(options.iedriver_version).to eq '3.141.0'
|
314
|
+
expect(options.max_duration).to eq 300
|
315
|
+
expect(options.name).to eq 'Sample Test Name'
|
316
|
+
expect(options.parent_tunnel).to eq 'Mommy'
|
317
|
+
expect(options.prerun).to eq prerun
|
318
|
+
expect(options.priority).to eq 0
|
319
|
+
expect(options.public).to eq 'team'
|
320
|
+
expect(options.record_logs).to eq false
|
321
|
+
expect(options.record_screenshots).to eq false
|
322
|
+
expect(options.record_video).to eq false
|
323
|
+
expect(options.screen_resolution).to eq '10x10'
|
324
|
+
expect(options.selenium_version).to eq '3.141.59'
|
325
|
+
expect(options.tags).to eq tags
|
326
|
+
expect(options.time_zone).to eq 'San Francisco'
|
327
|
+
expect(options.tunnel_identifier).to eq 'tunnelname'
|
328
|
+
expect(options.video_upload_on_pass).to eq false
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'raises exception if value not recognized' do
|
332
|
+
options = Options.new
|
333
|
+
yaml = YAML.load_file('spec/deprecated_options.yml')
|
334
|
+
|
335
|
+
msg = 'foo is not a valid parameter for Options class'
|
336
|
+
expect { options.merge_capabilities(yaml['invalid_option']) }.to raise_exception(ArgumentError, msg)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
describe '#capabilities' do
|
341
|
+
it 'correctly generates capabilities for w3c values' do
|
342
|
+
proxy = Selenium::WebDriver::Proxy.new(ssl: 'foo')
|
343
|
+
timeouts = {implicit: 1,
|
344
|
+
page_load: 59,
|
345
|
+
script: 29}
|
346
|
+
|
347
|
+
options = Options.new(browser_name: 'firefox',
|
348
|
+
platform_name: 'Mac',
|
349
|
+
accept_insecure_certs: true,
|
350
|
+
page_load_strategy: 'eager',
|
351
|
+
proxy: proxy,
|
352
|
+
set_window_rect: true,
|
353
|
+
unhandled_prompt_behavior: 'accept',
|
354
|
+
strict_file_interactability: true,
|
355
|
+
timeouts: timeouts)
|
356
|
+
|
357
|
+
proxy_type = Selenium::WebDriver::VERSION[0] == '3' ? 'MANUAL' : 'manual'
|
358
|
+
|
359
|
+
expect(options.capabilities).to eq('browserName' => 'firefox',
|
360
|
+
'browserVersion' => 'latest',
|
361
|
+
'platformName' => 'Mac',
|
362
|
+
'acceptInsecureCerts' => true,
|
363
|
+
'pageLoadStrategy' => 'eager',
|
364
|
+
'proxy' => {'proxyType' => proxy_type, 'sslProxy' => 'foo'},
|
365
|
+
'setWindowRect' => true,
|
366
|
+
'unhandledPromptBehavior' => 'accept',
|
367
|
+
'strictFileInteractability' => true,
|
368
|
+
'timeouts' => {'implicit' => 1,
|
369
|
+
'pageLoad' => 59,
|
370
|
+
'script' => 29},
|
371
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'})
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'correctly generates capabilities for sauce values' do
|
375
|
+
custom_data = {foo: 'foo',
|
376
|
+
bar: 'bar'}
|
377
|
+
prerun = {executable: 'http://url.to/your/executable.exe',
|
378
|
+
args: ['--silent', '-a', '-q'],
|
379
|
+
background: false,
|
380
|
+
timeout: 120}
|
381
|
+
tags = %w[foo bar foobar]
|
382
|
+
sauce_options = {avoid_proxy: true,
|
383
|
+
build: 'Sample Build Name',
|
384
|
+
capture_performance: true,
|
385
|
+
chromedriver_version: '71',
|
386
|
+
command_timeout: 2,
|
387
|
+
custom_data: custom_data,
|
388
|
+
extended_debugging: true,
|
389
|
+
idle_timeout: 3,
|
390
|
+
iedriver_version: '3.141.0',
|
391
|
+
max_duration: 300,
|
392
|
+
name: 'Sample Test Name',
|
393
|
+
parent_tunnel: 'Mommy',
|
394
|
+
prerun: prerun,
|
395
|
+
priority: 0,
|
396
|
+
public: 'team',
|
397
|
+
record_logs: false,
|
398
|
+
record_screenshots: false,
|
399
|
+
record_video: false,
|
400
|
+
screen_resolution: '10x10',
|
401
|
+
selenium_version: '3.141.59',
|
402
|
+
tags: tags,
|
403
|
+
time_zone: 'San Francisco',
|
404
|
+
tunnel_identifier: 'tunnelname',
|
405
|
+
video_upload_on_pass: false}
|
406
|
+
|
407
|
+
options = Options.new(**sauce_options)
|
408
|
+
|
409
|
+
prerun_caps = {'executable' => 'http://url.to/your/executable.exe',
|
410
|
+
'args' => ['--silent', '-a', '-q'],
|
411
|
+
'background' => false,
|
412
|
+
'timeout' => 120}
|
413
|
+
|
414
|
+
expect(options.capabilities).to eq('browserName' => 'chrome',
|
415
|
+
'browserVersion' => 'latest',
|
416
|
+
'platformName' => 'Windows 10',
|
417
|
+
'sauce:options' => {'build' => 'Sample Build Name',
|
418
|
+
'avoidProxy' => true,
|
419
|
+
'capturePerformance' => true,
|
420
|
+
'chromedriverVersion' => '71',
|
421
|
+
'commandTimeout' => 2,
|
422
|
+
'customData' => {'foo' => 'foo',
|
423
|
+
'bar' => 'bar'},
|
424
|
+
'extendedDebugging' => true,
|
425
|
+
'idleTimeout' => 3,
|
426
|
+
'iedriverVersion' => '3.141.0',
|
427
|
+
'maxDuration' => 300,
|
428
|
+
'name' => 'Sample Test Name',
|
429
|
+
'parentTunnel' => 'Mommy',
|
430
|
+
'prerun' => prerun_caps,
|
431
|
+
'priority' => 0,
|
432
|
+
'public' => 'team',
|
433
|
+
'recordLogs' => false,
|
434
|
+
'recordScreenshots' => false,
|
435
|
+
'recordVideo' => false,
|
436
|
+
'screenResolution' => '10x10',
|
437
|
+
'seleniumVersion' => '3.141.59',
|
438
|
+
'tags' => %w[foo bar foobar],
|
439
|
+
'timeZone' => 'San Francisco',
|
440
|
+
'tunnelIdentifier' => 'tunnelname',
|
441
|
+
'videoUploadOnPass' => false})
|
442
|
+
end
|
443
|
+
|
444
|
+
it 'correctly generates capabilities for selenium object values' do
|
445
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(accept_insecure_certs: true,
|
446
|
+
page_load_strategy: 'eager')
|
447
|
+
browser_opts = Selenium::WebDriver::Chrome::Options.new(args: ['--foo'])
|
448
|
+
options = Options.new(selenium_options: [caps, browser_opts])
|
449
|
+
|
450
|
+
jwp_defaults = {'cssSelectorsEnabled' => true,
|
451
|
+
'javascriptEnabled' => true,
|
452
|
+
'nativeEvents' => false,
|
453
|
+
'platform' => 'ANY',
|
454
|
+
'rotatable' => false,
|
455
|
+
'takesScreenshot' => false,
|
456
|
+
'version' => ''}
|
457
|
+
|
458
|
+
expected_caps = {'browserName' => 'chrome',
|
459
|
+
'browserVersion' => 'latest',
|
460
|
+
'platformName' => 'Windows 10',
|
461
|
+
'acceptInsecureCerts' => true,
|
462
|
+
'pageLoadStrategy' => 'eager',
|
463
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11'},
|
464
|
+
'goog:chromeOptions' => {'args' => ['--foo']}}
|
465
|
+
|
466
|
+
expected = Selenium::WebDriver::VERSION[0] == '3' ? jwp_defaults.merge(expected_caps) : expected_caps
|
467
|
+
|
468
|
+
expect(options.capabilities).to eq expected
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|