sauce_bindings 1.1.0 → 1.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/.rubocop.yml +2 -2
- data/CHANGES.md +34 -0
- data/README.md +1 -1
- data/Rakefile +13 -1
- 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 +7 -1
- data/lib/sauce_bindings/vdc_configurations.rb +13 -0
- data/lib/sauce_bindings/version.rb +1 -1
- data/lib/sauce_bindings.rb +7 -0
- data/sauce_bindings.gemspec +5 -3
- data/spec/deprecated_options.yml +56 -0
- data/spec/examples/accessibility_spec.rb +32 -0
- data/spec/examples/axe.min.js +1 -0
- data/spec/examples/browser_options_spec.rb +2 -4
- data/spec/examples/{basic_options_spec.rb → common_options_spec.rb} +5 -6
- 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 +1 -3
- data/spec/integration/accessibility_spec.rb +59 -0
- data/spec/integration/desktop_spec.rb +18 -14
- 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 +45 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7512f163c74551644149ae5452bf7e8f72977cef83e90134c26bd3c1a07f352c
|
4
|
+
data.tar.gz: 87248ccb9a002564dc97f05380db06e55ee4cb0fb6599d5fb9fcc0dca7ee27e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 796b7da1beb7307122675d78f8b2fd698ab71c5b5ce20f887cb288a14d880e3abc1a0a2f9219962d6b3040b33c7ab26c97dc8977e04b6681da1159ca3f0ab85f
|
7
|
+
data.tar.gz: cafb5b1b25caf038eb537b15a552ba6242ab2493c2005c71ca8a2e15424c364ab81ca3a9a183e4606d94be7de55b06cec356e7249c78653c4f29d0a42d0f8595
|
data/.rubocop.yml
CHANGED
data/CHANGES.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
### 1.2.1 - March 1, 2022
|
2
|
+
|
3
|
+
* Added latest Windows and Mac platforms
|
4
|
+
|
5
|
+
### 1.2.0 - July 12, 2021
|
6
|
+
|
7
|
+
* Accessibility functionality via Sa11y
|
8
|
+
|
9
|
+
### 1.1.1 - July 10, 2021
|
10
|
+
|
11
|
+
* `Options` class methods only allow setting valid options for the provided browser
|
12
|
+
* `Options` class supports Edge browser
|
13
|
+
* Support Selenium 4
|
14
|
+
|
15
|
+
### 1.1.0 - May 30, 2021
|
16
|
+
|
17
|
+
* Build Name support for Github Actions
|
18
|
+
* APAC data center tentatively supported
|
19
|
+
* Update `Options` to be constructed with class methods for browsers
|
20
|
+
|
21
|
+
### 1.0.0 - April 24, 2020
|
22
|
+
|
23
|
+
* Link to job on Sauce UI in STDOUT
|
24
|
+
|
25
|
+
### 1.0.0.beta1 - March 10, 2020
|
26
|
+
|
27
|
+
* `Options` class to construct capabilities
|
28
|
+
* `Session` class to wrap driver instance
|
29
|
+
* `Session#data_center=` to choose data center
|
30
|
+
* `Options` automatically uses default value for `build` name
|
31
|
+
* `Options` class accepts Selenium `Options` classes as argument
|
32
|
+
* `Options` accepts serialized information via a `Hash`
|
33
|
+
* `CapybaraSession` class for special Capybara support
|
34
|
+
* Sauce options for `user` and `access_key` must be obtained by ENV variables
|
data/README.md
CHANGED
@@ -62,7 +62,7 @@ browser_options = Selenium::WebDriver::Firefox::Options.new('args' => ['-foo'])
|
|
62
62
|
```
|
63
63
|
|
64
64
|
### Session class
|
65
|
-
####
|
65
|
+
#### Initializing a Session
|
66
66
|
`Session` class gets initialized with an `Options` instance. If you want the
|
67
67
|
default settings (latest Chrome version on Windows 10), you don't even need to use an `Options` instance:
|
68
68
|
```ruby
|
data/Rakefile
CHANGED
@@ -5,4 +5,16 @@ require 'rspec/core/rake_task'
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
8
|
+
RSpec::Core::RakeTask.new(:examples) do |spec|
|
9
|
+
spec.pattern = 'spec/examples/*_spec.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:unit) do |spec|
|
13
|
+
spec.pattern = 'spec/unit/*_spec.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:integration) do |spec|
|
17
|
+
spec.pattern = 'spec/integration/*_spec.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %i[examples unit integration]
|
@@ -11,26 +11,36 @@ module SauceBindings
|
|
11
11
|
|
12
12
|
def chrome(**opts)
|
13
13
|
opts[:browser_name] = 'chrome'
|
14
|
+
opts[:valid_options] = ChromeConfigurations.valid_options
|
14
15
|
Options.new(**opts)
|
15
16
|
end
|
16
17
|
|
17
18
|
def edge(**opts)
|
19
|
+
if Selenium::WebDriver::VERSION[0] == '3'
|
20
|
+
raise ArgumentError, 'Selenium 3 is not compatible with the Chromium based Microsoft Edge.'
|
21
|
+
end
|
22
|
+
|
18
23
|
opts[:browser_name] = 'MicrosoftEdge'
|
24
|
+
opts[:valid_options] = EdgeConfigurations.valid_options
|
19
25
|
Options.new(**opts)
|
20
26
|
end
|
21
27
|
|
22
28
|
def firefox(**opts)
|
23
29
|
opts[:browser_name] = 'firefox'
|
30
|
+
opts[:valid_options] = FirefoxConfigurations.valid_options
|
24
31
|
Options.new(**opts)
|
25
32
|
end
|
26
33
|
|
27
34
|
def ie(**opts)
|
28
35
|
opts[:browser_name] = 'internet explorer'
|
36
|
+
opts[:valid_options] = IEConfigurations.valid_options
|
29
37
|
Options.new(**opts)
|
30
38
|
end
|
31
39
|
|
32
40
|
def safari(**opts)
|
33
41
|
opts[:browser_name] = 'safari'
|
42
|
+
opts[:platform_name] ||= 'macOS 11'
|
43
|
+
opts[:valid_options] = SafariConfigurations.valid_options
|
34
44
|
Options.new(**opts)
|
35
45
|
end
|
36
46
|
end
|
@@ -49,17 +59,20 @@ module SauceBindings
|
|
49
59
|
record_video screen_resolution selenium_version tags time_zone tunnel_identifier video_upload_on_pass
|
50
60
|
capture_performance].freeze
|
51
61
|
|
52
|
-
|
53
|
-
:set_window_rect, :timeouts, :unhandled_prompt_behavior, :strict_file_interactability, :avoid_proxy,
|
54
|
-
:build, :chromedriver_version, :command_timeout, :custom_data, :extended_debugging, :idle_timeout,
|
55
|
-
:iedriver_version, :max_duration, :name, :parent_tunnel, :prerun, :priority, :public, :record_logs,
|
56
|
-
:record_screenshots, :record_video, :screen_resolution, :selenium_version, :tags, :time_zone,
|
57
|
-
:tunnel_identifier, :video_upload_on_pass, :capture_performance
|
58
|
-
attr_reader :selenium_options
|
62
|
+
attr_reader :selenium_options, :timeouts
|
59
63
|
|
60
64
|
def initialize(**opts)
|
61
|
-
|
62
|
-
|
65
|
+
se_options = Array(opts.delete(:selenium_options))
|
66
|
+
valid_options = opts.delete(:valid_options)
|
67
|
+
if valid_options.nil?
|
68
|
+
valid_options = SAUCE + W3C
|
69
|
+
warn 'Using `Options.new(opts)` directly is deprecated, use static methods for desired browser instead; ' \
|
70
|
+
'e.g., `Options.chrome(opts)` or `Options.safari(opts)'
|
71
|
+
end
|
72
|
+
|
73
|
+
create_variables(valid_options, opts)
|
74
|
+
@selenium_options = se_options.map(&:as_json).inject(:merge) || {}
|
75
|
+
parse_selenium_options(se_options)
|
63
76
|
@build ||= build_name
|
64
77
|
|
65
78
|
@browser_name ||= selenium_options['browserName'] || 'chrome'
|
@@ -70,17 +83,13 @@ module SauceBindings
|
|
70
83
|
def capabilities
|
71
84
|
caps = selenium_options.dup
|
72
85
|
W3C.each do |key|
|
73
|
-
value =
|
74
|
-
|
75
|
-
value = parse_w3c_key(key, value)
|
76
|
-
caps[key] = value unless value.nil?
|
86
|
+
value = parse_w3c_key(key)
|
87
|
+
caps[self.class.camel_case(key)] = value unless value.nil?
|
77
88
|
end
|
78
89
|
caps['sauce:options'] = {}
|
79
90
|
SAUCE.each do |key|
|
80
|
-
value =
|
81
|
-
|
82
|
-
value = parse_sauce_key(key, value)
|
83
|
-
caps['sauce:options'][key] = value unless value.nil?
|
91
|
+
value = parse_sauce_key(key)
|
92
|
+
caps['sauce:options'][self.class.camel_case(key)] = value unless value.nil?
|
84
93
|
end
|
85
94
|
caps
|
86
95
|
end
|
@@ -90,11 +99,7 @@ module SauceBindings
|
|
90
99
|
opts.each do |key, value|
|
91
100
|
raise ArgumentError, "#{key} is not a valid parameter for Options class" unless respond_to?("#{key}=")
|
92
101
|
|
93
|
-
if value.is_a?(Hash)
|
94
|
-
value = value.each_with_object({}) do |(old_key, val), updated|
|
95
|
-
updated[old_key.to_sym] = val
|
96
|
-
end
|
97
|
-
end
|
102
|
+
value = value.transform_keys(&:to_sym) if value.is_a?(Hash)
|
98
103
|
|
99
104
|
send("#{key}=", value)
|
100
105
|
end
|
@@ -102,59 +107,124 @@ module SauceBindings
|
|
102
107
|
|
103
108
|
private
|
104
109
|
|
105
|
-
def
|
106
|
-
|
110
|
+
def key_value(key)
|
111
|
+
send(key)
|
112
|
+
rescue NoMethodError
|
113
|
+
# Ignored
|
114
|
+
end
|
115
|
+
|
116
|
+
def parse_w3c_key(key)
|
117
|
+
value = send(key)
|
118
|
+
|
119
|
+
if key == :proxy && value
|
107
120
|
value.as_json
|
108
|
-
elsif key ==
|
109
|
-
value
|
110
|
-
|
121
|
+
elsif key == :timeouts
|
122
|
+
if value
|
123
|
+
warn ':timeouts is deprecated, use :implicit_wait_timeout, :page_load_timeout or :script_timeout directly; ' \
|
124
|
+
'(ensure the values are set as seconds not milliseconds)'
|
125
|
+
value.transform_keys do |old_key|
|
126
|
+
self.class.camel_case(old_key)
|
127
|
+
end
|
128
|
+
else
|
129
|
+
manage_timeouts
|
111
130
|
end
|
112
131
|
else
|
113
132
|
value
|
114
133
|
end
|
115
134
|
end
|
116
135
|
|
117
|
-
def
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
136
|
+
def manage_timeouts
|
137
|
+
timeouts = {}
|
138
|
+
timeouts['implicit'] = ms_multiplier(@implicit_wait_timeout) if @implicit_wait_timeout
|
139
|
+
timeouts['pageLoad'] = ms_multiplier(@page_load_timeout) if @page_load_timeout
|
140
|
+
timeouts['script'] = ms_multiplier(@script_timeout) if @script_timeout
|
141
|
+
timeouts unless timeouts.empty?
|
142
|
+
end
|
143
|
+
|
144
|
+
def ms_multiplier(int)
|
145
|
+
raise(ArgumentError, 'Timeouts need to be entered as seconds not milliseconds') if int > 600
|
146
|
+
|
147
|
+
int * 1000
|
148
|
+
end
|
149
|
+
|
150
|
+
def parse_sauce_key(key)
|
151
|
+
value = key_value(key)
|
152
|
+
|
153
|
+
case key
|
154
|
+
when :prerun
|
155
|
+
camelize_keys(value)
|
156
|
+
when :custom_data
|
157
|
+
camelize_keys(value)
|
158
|
+
when :disable_record_video
|
159
|
+
!send(:record_video)
|
160
|
+
when :disable_video_upload_on_pass
|
161
|
+
!send(:video_upload_on_pass)
|
162
|
+
when :disable_record_screenshots
|
163
|
+
!send(:record_screenshots)
|
164
|
+
when :disable_record_logs
|
165
|
+
!send(:record_logs)
|
126
166
|
else
|
127
167
|
value
|
128
168
|
end
|
129
169
|
end
|
130
170
|
|
171
|
+
def camelize_keys(hash)
|
172
|
+
hash&.transform_keys do |old_key|
|
173
|
+
self.class.camel_case(old_key)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
131
177
|
def parse_selenium_options(selenium_opts)
|
132
|
-
|
178
|
+
selenium_opts.each do |opt|
|
179
|
+
W3C.each do |capability|
|
180
|
+
value = option_value(opt, capability)
|
181
|
+
next if capability == :timeouts && value&.empty?
|
133
182
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
W3C.each do |capability|
|
140
|
-
send("#{capability}=", opt[capability]) if opt[capability]
|
183
|
+
if capability == :browser_name
|
184
|
+
@browser_name ||= BROWSER_NAMES[opt.class]
|
185
|
+
validate_browser_name(value || BROWSER_NAMES[opt.class])
|
186
|
+
elsif value
|
187
|
+
send("#{capability}=", value)
|
141
188
|
end
|
142
189
|
end
|
143
190
|
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def option_value(opt, capability)
|
194
|
+
if opt.respond_to?(capability)
|
195
|
+
begin
|
196
|
+
opt.send(capability)
|
197
|
+
rescue KeyError
|
198
|
+
# Ignored
|
199
|
+
end
|
200
|
+
elsif opt.respond_to?(:[])
|
201
|
+
opt[capability]
|
202
|
+
end
|
203
|
+
end
|
144
204
|
|
145
|
-
|
205
|
+
def validate_browser_name(browser)
|
206
|
+
return if @browser_name.nil? || browser == @browser_name
|
207
|
+
|
208
|
+
raise ArgumentError, "Selenium class identifies capabilities for #{browser}, which does not match the " \
|
209
|
+
"provided browser name: #{@browser_name}"
|
146
210
|
end
|
147
211
|
|
148
212
|
def create_variables(key, opts)
|
149
213
|
key.each do |option|
|
150
|
-
|
214
|
+
singleton_class.class_eval { attr_accessor option }
|
151
215
|
next unless opts.key?(option)
|
152
216
|
|
153
217
|
instance_variable_set("@#{option}", opts.delete(option))
|
154
218
|
end
|
219
|
+
|
220
|
+
if opts.key?(:browser_name)
|
221
|
+
singleton_class.class_eval { attr_reader :browser_name }
|
222
|
+
@browser_name = opts.delete(:browser_name)
|
223
|
+
end
|
224
|
+
|
155
225
|
return if opts.empty?
|
156
226
|
|
157
|
-
raise ArgumentError, "#{opts.inspect} are not valid parameters for Options class"
|
227
|
+
raise ArgumentError, "#{opts.inspect} are not valid parameters for Options class with #{@browser_name}"
|
158
228
|
end
|
159
229
|
|
160
230
|
def build_name
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'sauce_whisk'
|
4
|
+
require 'sa11y/analyze'
|
4
5
|
require 'selenium-webdriver'
|
5
6
|
|
6
7
|
module SauceBindings
|
@@ -15,7 +16,7 @@ module SauceBindings
|
|
15
16
|
attr_accessor :http_client, :listener
|
16
17
|
|
17
18
|
def initialize(options = nil, data_center: nil, http_client: nil, listener: nil)
|
18
|
-
@options = options || Options.
|
19
|
+
@options = options || Options.chrome
|
19
20
|
@http_client = http_client
|
20
21
|
@listener = listener
|
21
22
|
|
@@ -53,6 +54,11 @@ module SauceBindings
|
|
53
54
|
@data_center = data_center
|
54
55
|
end
|
55
56
|
|
57
|
+
def accessibility_results(js_lib: nil, frames: true, cross_origin: false)
|
58
|
+
sa11y = Sa11y::Analyze.new(driver, js_lib: js_lib, frames: frames, cross_origin: cross_origin)
|
59
|
+
sa11y.results
|
60
|
+
end
|
61
|
+
|
56
62
|
def url
|
57
63
|
@url ||= "https://#{@username}:#{@access_key}@#{DATA_CENTERS[data_center]}:443/wd/hub"
|
58
64
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SauceBindings
|
4
|
+
class VDCConfigurations < BaseConfigurations
|
5
|
+
def self.valid_options
|
6
|
+
super + %i[browser_version page_load_strategy accept_insecure_certs proxy
|
7
|
+
strict_file_interactability unhandled_prompt_behavior implicit_wait_timeout
|
8
|
+
page_load_timeout script_timeout record_video video_upload_on_pass
|
9
|
+
record_screenshots record_logs max_duration command_timeout
|
10
|
+
idle_timeout prerun priority screen_resolution time_zone]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/sauce_bindings.rb
CHANGED
@@ -3,3 +3,10 @@
|
|
3
3
|
require 'sauce_bindings/version'
|
4
4
|
require 'sauce_bindings/options'
|
5
5
|
require 'sauce_bindings/session'
|
6
|
+
require 'sauce_bindings/base_configurations'
|
7
|
+
require 'sauce_bindings/vdc_configurations'
|
8
|
+
require 'sauce_bindings/chrome_configurations'
|
9
|
+
require 'sauce_bindings/edge_configurations'
|
10
|
+
require 'sauce_bindings/firefox_configurations'
|
11
|
+
require 'sauce_bindings/ie_configurations'
|
12
|
+
require 'sauce_bindings/safari_configurations'
|
data/sauce_bindings.gemspec
CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = SauceBindings::VERSION
|
10
10
|
spec.authors = ['Titus Fortner']
|
11
11
|
spec.email = ['titusfortner@gmail.com']
|
12
|
+
spec.required_ruby_version = '>= 2.5.0'
|
12
13
|
|
13
14
|
spec.summary = 'Simple interface for interacting with Sauce Labs.'
|
14
15
|
spec.description = 'Reduces complexity in user code for running Selenium tests on Sauce Labs'
|
@@ -23,11 +24,12 @@ Gem::Specification.new do |spec|
|
|
23
24
|
spec.add_development_dependency 'capybara', '~> 3.16'
|
24
25
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
25
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
-
spec.add_development_dependency 'rubocop', '~>0
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 1.0'
|
27
28
|
spec.add_development_dependency 'rubocop-performance'
|
28
|
-
spec.add_development_dependency 'rubocop-rspec', '~>
|
29
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
29
30
|
spec.add_development_dependency 'webmock', '~> 3.5'
|
30
31
|
|
32
|
+
spec.add_runtime_dependency 'sa11y', '~> 0.2.0'
|
31
33
|
spec.add_runtime_dependency 'sauce_whisk'
|
32
|
-
spec.add_runtime_dependency 'selenium-webdriver', '
|
34
|
+
spec.add_runtime_dependency 'selenium-webdriver', '>= 3.142.7'
|
33
35
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
example_values:
|
2
|
+
browser_name: 'firefox'
|
3
|
+
browser_version: '123'
|
4
|
+
platform_name: 'Mac'
|
5
|
+
accept_insecure_certs: true
|
6
|
+
page_load_strategy: 'eager'
|
7
|
+
set_window_rect: true
|
8
|
+
unhandled_prompt_behavior: "accept"
|
9
|
+
strict_file_interactability: true
|
10
|
+
timeouts:
|
11
|
+
implicit: 1
|
12
|
+
page_load: 59
|
13
|
+
script: 29
|
14
|
+
avoid_proxy: true
|
15
|
+
build: 'Sample Build Name'
|
16
|
+
capture_performance: true
|
17
|
+
chromedriver_version: '71'
|
18
|
+
command_timeout: 2
|
19
|
+
custom_data:
|
20
|
+
foo: 'foo'
|
21
|
+
bar: 'bar'
|
22
|
+
extended_debugging: true
|
23
|
+
idle_timeout: 3
|
24
|
+
iedriver_version: '3.141.0'
|
25
|
+
max_duration: 300
|
26
|
+
name: 'Sample Test Name'
|
27
|
+
parent_tunnel: 'Mommy'
|
28
|
+
prerun:
|
29
|
+
executable: "http://url.to/your/executable.exe"
|
30
|
+
args:
|
31
|
+
- --silent
|
32
|
+
- -a
|
33
|
+
- -q
|
34
|
+
background: false
|
35
|
+
timeout: 120
|
36
|
+
priority: 0
|
37
|
+
public: 'team'
|
38
|
+
record_logs: false
|
39
|
+
record_screenshots: false
|
40
|
+
record_video: false
|
41
|
+
screen_resolution: '10x10'
|
42
|
+
selenium_version: '3.141.59'
|
43
|
+
tags:
|
44
|
+
- foo
|
45
|
+
- bar
|
46
|
+
- foobar
|
47
|
+
time_zone: 'San Francisco'
|
48
|
+
tunnel_identifier: 'tunnelname'
|
49
|
+
video_upload_on_pass: false
|
50
|
+
|
51
|
+
invalid_option:
|
52
|
+
foo: "bar"
|
53
|
+
browser_name: "firefox"
|
54
|
+
browser_version: "70"
|
55
|
+
platform_name: "MacOS 10.12"
|
56
|
+
record_screenshots: false
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Create Session' do
|
7
|
+
it 'starts session' do
|
8
|
+
# 1. Create Session object with the desired Data Center
|
9
|
+
session = SauceBindings::Session.new
|
10
|
+
|
11
|
+
# 2. Start Session to get the Driver
|
12
|
+
driver = session.start
|
13
|
+
|
14
|
+
# 3. Use the driver in your tests just like normal
|
15
|
+
driver.get('https://www.saucedemo.com/')
|
16
|
+
|
17
|
+
# 4a. Get accessibility default results with frame support
|
18
|
+
session.accessibility_results
|
19
|
+
|
20
|
+
# 4b. Get accessibility default results without frame support
|
21
|
+
session.accessibility_results(frames: false)
|
22
|
+
|
23
|
+
# 4c. Get accessibility results with cross origin frame support
|
24
|
+
session.accessibility_results(cross_origin: true)
|
25
|
+
|
26
|
+
# 4d. Get accessibility results with a different version of Axe Core JS Library
|
27
|
+
session.accessibility_results(js_lib: File.read(File.expand_path('axe.min.js', __dir__)))
|
28
|
+
|
29
|
+
# 5. Stop the Session with whether the test passed or failed
|
30
|
+
session.stop(true)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
// Blank file
|
@@ -4,14 +4,12 @@ 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
|
-
browser_options = Selenium::WebDriver::
|
9
|
+
browser_options = Selenium::WebDriver::Chrome::Options.new(args: ['--start-fullscreen'])
|
12
10
|
|
13
11
|
# 2. Create Sauce Options object with the Browser Options object instance
|
14
|
-
sauce_options = SauceBindings::Options.
|
12
|
+
sauce_options = SauceBindings::Options.chrome(selenium_options: browser_options)
|
15
13
|
|
16
14
|
# 3. Create Session object with SauceOptions object instance
|
17
15
|
session = SauceBindings::Session.new(sauce_options)
|
@@ -3,13 +3,12 @@
|
|
3
3
|
require 'sauce_bindings'
|
4
4
|
require 'rspec'
|
5
5
|
|
6
|
-
describe '
|
7
|
-
before { WebMock.allow_net_connect! }
|
8
|
-
|
6
|
+
describe 'Common Options' do
|
9
7
|
it 'creates session' do
|
10
|
-
# 1. Create
|
11
|
-
sauce_options = SauceBindings::Options.firefox(browser_version: '
|
12
|
-
platform_name: 'Windows 8'
|
8
|
+
# 1. Create Options instance with common w3c options
|
9
|
+
sauce_options = SauceBindings::Options.firefox(browser_version: '88.0',
|
10
|
+
platform_name: 'Windows 8',
|
11
|
+
unhandled_prompt_behavior: 'ignore')
|
13
12
|
|
14
13
|
# 2. Create Session object with SauceOptions object instance
|
15
14
|
session = SauceBindings::Session.new(sauce_options)
|
@@ -4,12 +4,10 @@ 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,
|
12
|
-
idle_timeout:
|
10
|
+
idle_timeout: 45,
|
13
11
|
time_zone: 'Alaska')
|
14
12
|
|
15
13
|
# 2. Create Session object with SauceOptions object instance
|