sauce_bindings 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -6
- data/CHANGES.md +46 -0
- data/LICENSE.txt +1 -1
- data/README.md +11 -87
- data/Rakefile +15 -1
- data/lib/sauce_bindings/capybara_session.rb +0 -3
- data/lib/sauce_bindings/errors.rb +7 -0
- data/lib/sauce_bindings/logger.rb +20 -0
- data/lib/sauce_bindings/options.rb +23 -5
- data/lib/sauce_bindings/session.rb +98 -18
- data/lib/sauce_bindings/version.rb +1 -1
- data/lib/sauce_bindings.rb +8 -0
- data/sauce_bindings.gemspec +7 -6
- data/spec/examples/accessibility_spec.rb +32 -0
- data/spec/examples/axe.min.js +1 -0
- data/spec/examples/browser_options_spec.rb +2 -2
- data/spec/examples/{basic_options_spec.rb → common_options_spec.rb} +4 -3
- data/spec/examples/sauce_options_spec.rb +1 -1
- data/spec/integration/accessibility_spec.rb +59 -0
- data/spec/integration/desktop_spec.rb +33 -4
- data/spec/spec_helper.rb +39 -1
- data/spec/unit/capybara_session_spec.rb +10 -20
- data/spec/unit/deprecated_options_spec.rb +479 -456
- data/spec/unit/options_spec.rb +121 -154
- data/spec/unit/session_spec.rb +437 -84
- metadata +56 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6fa82b7cd3b5e29fcfdb6e77f98f9dd7cb309d51523427de63e586b6094ac75
|
4
|
+
data.tar.gz: 8e8b4147c5a77459710f52cb36e927018050c34b4fff186960ddbb433ada23a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b0970705b477b0df8ad01f5f162b8e64731b76396cbe6c2038f10a501a4d5769aedfa00e33429ca8f0fc2e905a0efd6187b09f3d4e2ceb9262334183f596bbc
|
7
|
+
data.tar.gz: d4336f5ef88d197a1995142fb7ceb36c6dfe69038d8ac2204cd9fe3e04e82eeef2ad810279c9403977b1b27014f56f72ac6805d4dc5299a5917e6bbf386e4e1c
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.5
|
2
|
+
TargetRubyVersion: 2.7.5
|
3
3
|
|
4
4
|
require:
|
5
5
|
- rubocop-rspec
|
@@ -9,7 +9,7 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
9
9
|
EnforcedStyle: no_space
|
10
10
|
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 27
|
13
13
|
|
14
14
|
Metrics/BlockLength:
|
15
15
|
Exclude:
|
@@ -22,14 +22,13 @@ Metrics/PerceivedComplexity:
|
|
22
22
|
Max: 11
|
23
23
|
|
24
24
|
Metrics/ClassLength:
|
25
|
-
|
26
|
-
- 'lib/sauce_bindings/options.rb'
|
25
|
+
Enabled: false
|
27
26
|
|
28
27
|
Metrics/LineLength:
|
29
28
|
Max: 120
|
30
29
|
|
31
30
|
Metrics/MethodLength:
|
32
|
-
Max:
|
31
|
+
Max: 20
|
33
32
|
|
34
33
|
Metrics/ModuleLength:
|
35
34
|
CountComments: false
|
@@ -55,4 +54,11 @@ RSpec/MultipleExpectations:
|
|
55
54
|
Enabled: false
|
56
55
|
|
57
56
|
RSpec/DescribedClass:
|
58
|
-
EnforcedStyle: explicit
|
57
|
+
EnforcedStyle: explicit
|
58
|
+
|
59
|
+
Lint/ConstantDefinitionInBlock:
|
60
|
+
Exclude:
|
61
|
+
- 'spec/spec_helper.rb'
|
62
|
+
|
63
|
+
Style/BlockDelimiters:
|
64
|
+
EnforcedStyle: braces_for_chaining
|
data/CHANGES.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
### 1.3.0 - June 15, 2022
|
2
|
+
|
3
|
+
* Fix links to work all data centers
|
4
|
+
* Manage credentials in Options instead of Session
|
5
|
+
* Deprecate using magic strings for stopping a session
|
6
|
+
* Implement pausing — `Session#pause`
|
7
|
+
* Implement commenting in Sauce command list — `Session#annotate`
|
8
|
+
* Implement logging control — `Session#enable_logs`, `Session#disable_logs`
|
9
|
+
* Implement network control — `Session#stop_network`, `Session#start_network`
|
10
|
+
* Implement updating test information — `Session#change_name`, `Session#tags=`
|
11
|
+
* Require Selenium 4 and Ruby 2.7
|
12
|
+
|
13
|
+
### 1.2.1 - March 1, 2022
|
14
|
+
|
15
|
+
* Added latest Windows and Mac platforms
|
16
|
+
|
17
|
+
### 1.2.0 - July 12, 2021
|
18
|
+
|
19
|
+
* Accessibility functionality via Sa11y
|
20
|
+
|
21
|
+
### 1.1.1 - July 10, 2021
|
22
|
+
|
23
|
+
* `Options` class methods only allow setting valid options for the provided browser
|
24
|
+
* `Options` class supports Edge browser
|
25
|
+
* Support Selenium 4
|
26
|
+
|
27
|
+
### 1.1.0 - May 30, 2021
|
28
|
+
|
29
|
+
* Build Name support for Github Actions
|
30
|
+
* APAC data center tentatively supported
|
31
|
+
* Update `Options` to be constructed with class methods for browsers
|
32
|
+
|
33
|
+
### 1.0.0 - April 24, 2020
|
34
|
+
|
35
|
+
* Link to job on Sauce UI in STDOUT
|
36
|
+
|
37
|
+
### 1.0.0.beta1 - March 10, 2020
|
38
|
+
|
39
|
+
* `Options` class to construct capabilities
|
40
|
+
* `Session` class to wrap driver instance
|
41
|
+
* `Session#data_center=` to choose data center
|
42
|
+
* `Options` automatically uses default value for `build` name
|
43
|
+
* `Options` class accepts Selenium `Options` classes as argument
|
44
|
+
* `Options` accepts serialized information via a `Hash`
|
45
|
+
* `CapybaraSession` class for special Capybara support
|
46
|
+
* Sauce options for `user` and `access_key` must be obtained by ENV variables
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,13 @@
|
|
1
1
|
# Sauce Bindings
|
2
|
+
|
2
3
|
## A library for interacting with Sauce Labs using Ruby
|
3
4
|
|
4
5
|
This gem is intended as a way to interact with Sauce Labs in an obvious and straightforward way.
|
5
6
|
|
6
|
-
## Installation
|
7
|
-
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
gem 'sauce_bindings'
|
12
|
-
```
|
13
|
-
|
14
|
-
And then execute:
|
7
|
+
## User Installation & Usage
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
Or install it yourself as:
|
19
|
-
|
20
|
-
$ gem install sauce_bindings
|
9
|
+
Please see the [documentation on our website](https://opensource.saucelabs.com/sauce_bindings),
|
10
|
+
and select the "Ruby" tab for code examples.
|
21
11
|
|
22
12
|
## Running Tests
|
23
13
|
|
@@ -25,79 +15,13 @@ To run tests for the Ruby Sauce Bindings, execute
|
|
25
15
|
|
26
16
|
$ bundle exec rake
|
27
17
|
|
28
|
-
##
|
29
|
-
|
30
|
-
`
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
If you want the default settings (the latest Chrome version on Windows 10) with no other settings,
|
36
|
-
this is all the code you need:
|
37
|
-
```
|
38
|
-
sauce_opts = SauceBindings::Options.new
|
39
|
-
```
|
40
|
-
To specify additional
|
41
|
-
[Sauce Labs supported settings](https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options),
|
42
|
-
simply pass these in as a `Hash`, or use an accessor:
|
43
|
-
```
|
44
|
-
sauce_options = {screen_resolution: '1080x720',
|
45
|
-
browser_name: 'Firefox',
|
46
|
-
platform_name: 'Mac OS'}
|
47
|
-
sauce_opts = SauceBindings::Options.new(sauce_options)
|
48
|
-
sauce_opts.idle_timeout = 100
|
49
|
-
```
|
50
|
-
if you have additional browser specific settings, or
|
51
|
-
[webdriver w3c spec compliant settings](http://w3c.github.io/webdriver/webdriver-spec.html#capabilities), in
|
52
|
-
Selenium 3.x you need to generate each of these separately; see the `Session` class below for how to use it:
|
53
|
-
```
|
54
|
-
sauce_options = SauceBindings::Options.new(screen_resolution: '1080x720',
|
55
|
-
browser_name: 'Firefox',
|
56
|
-
platform_name: 'Mac OS')
|
57
|
-
|
58
|
-
selenium_options = Selenium::WebDriver::Remote::Capabilities.new(accept_insecure_certs: false,
|
59
|
-
page_load_strategy: 'eager'}
|
60
|
-
|
61
|
-
browser_options = Selenium::WebDriver::Firefox::Options.new('args' => ['-foo'])
|
62
|
-
```
|
63
|
-
|
64
|
-
### Session class
|
65
|
-
#### Intializing a Session
|
66
|
-
`Session` class gets initialized with an `Options` instance. If you want the
|
67
|
-
default settings (latest Chrome version on Windows 10), you don't even need to use an `Options` instance:
|
68
|
-
```ruby
|
69
|
-
@session = SauceBindings::Session.new
|
70
|
-
```
|
71
|
-
If you want something other than the default, create a Sauce `Option` instance (as generated in the section above,
|
72
|
-
then pass it into the constructor:
|
73
|
-
```ruby
|
74
|
-
@session = SauceBindings::Session.new(sauce_opts)
|
75
|
-
```
|
76
|
-
If you also have Selenium or Browser options as described above, then you pass them in with an `Array` like so:
|
77
|
-
```ruby
|
78
|
-
@session = SauceBindings::Session.new([sauce_opts, se_opts, browser_opts])
|
79
|
-
```
|
80
|
-
|
81
|
-
#### Creating a driver instance
|
82
|
-
The `#start` method is required, and will return a `Selenium::WebDriver::<Browser>::Driver` instance,
|
83
|
-
and the `#stop` method will automatically quit the driver as well as ending the Sauce Labs session.
|
84
|
-
```ruby
|
85
|
-
session = SauceBindings::Session.new
|
86
|
-
driver = session.start
|
87
|
-
# Use the driver
|
88
|
-
session.stop
|
89
|
-
```
|
90
|
-
Note that the `Driver` instance can also be obtained at any time with the `#driver` method:
|
91
|
-
```ruby
|
92
|
-
session = SauceBindings::Session.new
|
93
|
-
session.start
|
94
|
-
driver = session.driver
|
95
|
-
# Use the driver
|
96
|
-
session.stop
|
97
|
-
```
|
98
|
-
#### Additional Session methods
|
99
|
-
We have a number of features we plan to add; stay tuned to see what additional features are made available. If you
|
100
|
-
have any request, please contact the Sauce Labs Solution Architect team.
|
18
|
+
## Building and Releasing
|
19
|
+
|
20
|
+
Use `gem` instead of `rake` so that it isn't auto-tagged on github
|
21
|
+
|
22
|
+
* Bump `SauceBindings::VERSION`
|
23
|
+
* `$ gem build sauce_bindings.gemspec`
|
24
|
+
* `$ gem push pkg/sauce_bindings-<VERSION>.gem`
|
101
25
|
|
102
26
|
## Contributing
|
103
27
|
|
data/Rakefile
CHANGED
@@ -5,4 +5,18 @@ require 'rspec/core/rake_task'
|
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
task default:
|
8
|
+
task default: %i[examples unit integration]
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:unit) do |spec|
|
11
|
+
spec.pattern = 'spec/unit/*_spec.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Run examples in parallel'
|
15
|
+
task :examples do
|
16
|
+
system 'parallel_split_test spec/examples/*_spec.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run integration tests in parallel'
|
20
|
+
task :integration do
|
21
|
+
system 'parallel_split_test spec/integration/*_spec.rb'
|
22
|
+
end
|
@@ -15,9 +15,6 @@ module SauceBindings
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def start
|
18
|
-
raise ArgumentError, "needs username; use `ENV['SAUCE_USERNAME']` or `Session#username=`" unless @username
|
19
|
-
raise ArgumentError, "needs access_key; use `ENV['SAUCE_ACCESS_KEY']` or `Session#access_key=`" unless @access_key
|
20
|
-
|
21
18
|
@capybara_driver = Capybara.current_session.driver
|
22
19
|
@driver = @capybara_driver.browser
|
23
20
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SauceBindings
|
4
|
+
#
|
5
|
+
# @example Enable full logging
|
6
|
+
# SauceBindings.logger.level = :debug
|
7
|
+
#
|
8
|
+
# @example Log to file
|
9
|
+
# SauceBindings.logger.output = 'webdrivers.log'
|
10
|
+
#
|
11
|
+
# @example Use logger manually
|
12
|
+
# SauceBindings.logger.info('This is info message')
|
13
|
+
# SauceBindings.logger.warn('This is warning message')
|
14
|
+
#
|
15
|
+
class Logger < Selenium::WebDriver::Logger
|
16
|
+
def initialize
|
17
|
+
super('SauceBindings')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -39,7 +39,7 @@ module SauceBindings
|
|
39
39
|
|
40
40
|
def safari(**opts)
|
41
41
|
opts[:browser_name] = 'safari'
|
42
|
-
opts[:platform_name] ||= 'macOS 11
|
42
|
+
opts[:platform_name] ||= 'macOS 11'
|
43
43
|
opts[:valid_options] = SafariConfigurations.valid_options
|
44
44
|
Options.new(**opts)
|
45
45
|
end
|
@@ -66,8 +66,9 @@ module SauceBindings
|
|
66
66
|
valid_options = opts.delete(:valid_options)
|
67
67
|
if valid_options.nil?
|
68
68
|
valid_options = SAUCE + W3C
|
69
|
-
|
70
|
-
|
69
|
+
SauceBindings.logger.deprecate('Using `Options.new(opts)` directly',
|
70
|
+
'static methods for desired browser',
|
71
|
+
id: :options_init) { '(e.g., `Options.chrome(opts)`)' }
|
71
72
|
end
|
72
73
|
|
73
74
|
create_variables(valid_options, opts)
|
@@ -86,7 +87,13 @@ module SauceBindings
|
|
86
87
|
value = parse_w3c_key(key)
|
87
88
|
caps[self.class.camel_case(key)] = value unless value.nil?
|
88
89
|
end
|
90
|
+
|
89
91
|
caps['sauce:options'] = {}
|
92
|
+
caps['sauce:options']['username'] = ENV['SAUCE_USERNAME'] ||
|
93
|
+
raise(ArgumentError, "needs username; use `ENV['SAUCE_USERNAME']`")
|
94
|
+
caps['sauce:options']['accessKey'] = ENV['SAUCE_ACCESS_KEY'] ||
|
95
|
+
raise(ArgumentError, "needs access key; use `ENV['SAUCE_ACCESS_KEY']`")
|
96
|
+
|
90
97
|
SAUCE.each do |key|
|
91
98
|
value = parse_sauce_key(key)
|
92
99
|
caps['sauce:options'][self.class.camel_case(key)] = value unless value.nil?
|
@@ -105,6 +112,14 @@ module SauceBindings
|
|
105
112
|
end
|
106
113
|
end
|
107
114
|
|
115
|
+
def mac?
|
116
|
+
@platform_name.include?('mac') || @platform_name.include?('OS X')
|
117
|
+
end
|
118
|
+
|
119
|
+
def windows?
|
120
|
+
@platform_name.include?('Windows')
|
121
|
+
end
|
122
|
+
|
108
123
|
private
|
109
124
|
|
110
125
|
def key_value(key)
|
@@ -120,8 +135,11 @@ module SauceBindings
|
|
120
135
|
value.as_json
|
121
136
|
elsif key == :timeouts
|
122
137
|
if value
|
123
|
-
|
124
|
-
|
138
|
+
SauceBindings.logger.deprecate(':timeouts',
|
139
|
+
':implicit_wait_timeout, :page_load_timeout or :script_timeout;',
|
140
|
+
id: :timeouts) do
|
141
|
+
'(ensure the values are set as seconds not milliseconds)'
|
142
|
+
end
|
125
143
|
value.transform_keys do |old_key|
|
126
144
|
self.class.camel_case(old_key)
|
127
145
|
end
|
@@ -1,17 +1,18 @@
|
|
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
|
7
8
|
class Session
|
8
|
-
DATA_CENTERS = {US_WEST: '
|
9
|
-
US_EAST: '
|
10
|
-
EU_CENTRAL: '
|
11
|
-
APAC_SOUTHEAST: '
|
9
|
+
DATA_CENTERS = {US_WEST: 'us-west-1',
|
10
|
+
US_EAST: 'us-east-1',
|
11
|
+
EU_CENTRAL: 'eu-central-1',
|
12
|
+
APAC_SOUTHEAST: 'apac-southeast-1'}.freeze
|
12
13
|
|
13
14
|
attr_writer :url
|
14
|
-
attr_reader :driver, :options, :data_center
|
15
|
+
attr_reader :driver, :options, :data_center, :session_id
|
15
16
|
attr_accessor :http_client, :listener
|
16
17
|
|
17
18
|
def initialize(options = nil, data_center: nil, http_client: nil, listener: nil)
|
@@ -19,27 +20,25 @@ module SauceBindings
|
|
19
20
|
@http_client = http_client
|
20
21
|
@listener = listener
|
21
22
|
|
22
|
-
@username = ENV['SAUCE_USERNAME']
|
23
|
-
@access_key = ENV['SAUCE_ACCESS_KEY']
|
24
23
|
self.data_center = data_center || :US_WEST
|
25
24
|
end
|
26
25
|
|
27
26
|
def start
|
28
|
-
raise ArgumentError, "needs username; use `ENV['SAUCE_USERNAME']`" unless @username
|
29
|
-
raise ArgumentError, "needs access_key; use `ENV['SAUCE_ACCESS_KEY']`" unless @access_key
|
30
|
-
|
31
27
|
@driver = Selenium::WebDriver.for :remote, to_selenium
|
28
|
+
@session_id = @driver.session_id
|
29
|
+
@driver
|
32
30
|
end
|
33
31
|
|
34
32
|
def stop(result)
|
35
33
|
return if @driver.nil?
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
unless result.is_a?(TrueClass) || result.is_a?(FalseClass)
|
36
|
+
raise ArgumentError, 'Result must be a boolean value representing whether a test has passed'
|
37
|
+
end
|
38
|
+
|
39
|
+
SauceWhisk::Jobs.change_status(@session_id, result)
|
40
|
+
print_results
|
41
|
+
|
43
42
|
@driver.quit
|
44
43
|
end
|
45
44
|
|
@@ -53,15 +52,96 @@ module SauceBindings
|
|
53
52
|
@data_center = data_center
|
54
53
|
end
|
55
54
|
|
55
|
+
def accessibility_results(js_lib: nil, frames: true, cross_origin: false)
|
56
|
+
validate_session_started('accessibility_results')
|
57
|
+
sa11y = Sa11y::Analyze.new(driver, js_lib: js_lib, frames: frames, cross_origin: cross_origin)
|
58
|
+
sa11y.results
|
59
|
+
end
|
60
|
+
|
61
|
+
def annotate(comment)
|
62
|
+
validate_session_started('annotate')
|
63
|
+
driver.execute_script("sauce:context=#{comment}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def pause
|
67
|
+
validate_session_started('pause')
|
68
|
+
driver.execute_script('sauce: break')
|
69
|
+
puts "\nThis test has been stopped; no more driver commands will be accepted"
|
70
|
+
puts "\nYou can take manual control of the test from the Sauce Labs UI here: #{test_link}"
|
71
|
+
@driver = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def disable_logging
|
75
|
+
validate_session_started('disable_logging')
|
76
|
+
driver.execute_script('sauce: disable log')
|
77
|
+
end
|
78
|
+
|
79
|
+
def enable_logging
|
80
|
+
validate_session_started('enable_logging')
|
81
|
+
driver.execute_script('sauce: enable log')
|
82
|
+
end
|
83
|
+
|
84
|
+
def stop_network
|
85
|
+
validate_session_started('stop_network')
|
86
|
+
unless options.mac?
|
87
|
+
error = "Can only start or stop the network on a Mac; current platform is: #{options.platform_name}"
|
88
|
+
raise InvalidPlatformError, error
|
89
|
+
end
|
90
|
+
|
91
|
+
driver.execute_script('sauce: stop network')
|
92
|
+
end
|
93
|
+
|
94
|
+
def start_network
|
95
|
+
validate_session_started('start_network')
|
96
|
+
unless options.mac?
|
97
|
+
error = "Can only start or stop the network on a Mac; current platform is: #{options.platform_name}"
|
98
|
+
raise InvalidPlatformError, error
|
99
|
+
end
|
100
|
+
|
101
|
+
driver.execute_script('sauce: start network')
|
102
|
+
end
|
103
|
+
|
104
|
+
def change_name(name)
|
105
|
+
validate_session_started('change_name')
|
106
|
+
|
107
|
+
driver.execute_script("sauce:job-name=#{name}")
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_tags(tags)
|
111
|
+
tags = Array(tags)
|
112
|
+
validate_session_started('tags=')
|
113
|
+
@driver.execute_script("sauce:job-tags=#{tags.join(',')}")
|
114
|
+
end
|
115
|
+
|
56
116
|
def url
|
57
|
-
@url ||= "https
|
117
|
+
@url ||= "https://ondemand.#{DATA_CENTERS[data_center]}.saucelabs.com/wd/hub"
|
58
118
|
end
|
59
119
|
|
60
120
|
def to_selenium
|
61
|
-
caps = {url: url,
|
121
|
+
caps = {url: url, capabilities: Selenium::WebDriver::Remote::Capabilities.new(options.capabilities)}
|
62
122
|
caps[:listener] = listener if listener
|
63
123
|
caps[:http_client] = http_client if http_client
|
64
124
|
caps
|
65
125
|
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def test_link
|
130
|
+
dc = data_center == :US_WEST ? '' : "#{DATA_CENTERS[data_center]}."
|
131
|
+
"https://app.#{dc}saucelabs.com/tests/#{@session_id}"
|
132
|
+
end
|
133
|
+
|
134
|
+
def validate_session_started(method)
|
135
|
+
raise SessionNotStartedError, "session must be started before executing ##{method}" unless @driver
|
136
|
+
end
|
137
|
+
|
138
|
+
def print_results
|
139
|
+
# Add output for the Sauce OnDemand Jenkins plugin
|
140
|
+
# The first print statement will automatically populate links on Jenkins to Sauce
|
141
|
+
# The second print statement will output the job link to logging/console
|
142
|
+
puts "SauceOnDemandSessionID=#{@session_id} job-name=#{@options.name}"
|
143
|
+
|
144
|
+
puts "Test Job Link: #{test_link}"
|
145
|
+
end
|
66
146
|
end
|
67
147
|
end
|
data/lib/sauce_bindings.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'sauce_bindings/version'
|
4
4
|
require 'sauce_bindings/options'
|
5
|
+
require 'sauce_bindings/errors'
|
5
6
|
require 'sauce_bindings/session'
|
6
7
|
require 'sauce_bindings/base_configurations'
|
7
8
|
require 'sauce_bindings/vdc_configurations'
|
@@ -10,3 +11,10 @@ require 'sauce_bindings/edge_configurations'
|
|
10
11
|
require 'sauce_bindings/firefox_configurations'
|
11
12
|
require 'sauce_bindings/ie_configurations'
|
12
13
|
require 'sauce_bindings/safari_configurations'
|
14
|
+
require 'sauce_bindings/logger'
|
15
|
+
|
16
|
+
module SauceBindings
|
17
|
+
def self.logger
|
18
|
+
@logger ||= Logger.new
|
19
|
+
end
|
20
|
+
end
|
data/sauce_bindings.gemspec
CHANGED
@@ -9,7 +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.
|
12
|
+
spec.required_ruby_version = '>= 2.7.0'
|
13
13
|
|
14
14
|
spec.summary = 'Simple interface for interacting with Sauce Labs.'
|
15
15
|
spec.description = 'Reduces complexity in user code for running Selenium tests on Sauce Labs'
|
@@ -22,13 +22,14 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
24
24
|
spec.add_development_dependency 'capybara', '~> 3.16'
|
25
|
-
spec.add_development_dependency '
|
25
|
+
spec.add_development_dependency 'climate_control', '~> 1.1'
|
26
|
+
spec.add_development_dependency 'parallel_split_test', '~> 0.10'
|
27
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
26
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
-
spec.add_development_dependency 'rubocop', '~> 1.0'
|
28
|
-
spec.add_development_dependency 'rubocop-performance'
|
29
29
|
spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
30
30
|
spec.add_development_dependency 'webmock', '~> 3.5'
|
31
31
|
|
32
|
-
spec.add_runtime_dependency '
|
33
|
-
spec.add_runtime_dependency '
|
32
|
+
spec.add_runtime_dependency 'sa11y', '~> 0.2.0'
|
33
|
+
spec.add_runtime_dependency 'sauce_whisk', '~> 0.3.2'
|
34
|
+
spec.add_runtime_dependency 'selenium-webdriver', '~> 4.0'
|
34
35
|
end
|
@@ -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
|
@@ -6,10 +6,10 @@ require 'rspec'
|
|
6
6
|
describe 'Browser Options' do
|
7
7
|
it 'creates session' do
|
8
8
|
# 1. Create Selenium Browser Options instance
|
9
|
-
browser_options = Selenium::WebDriver::
|
9
|
+
browser_options = Selenium::WebDriver::Chrome::Options.new(args: ['--start-fullscreen'])
|
10
10
|
|
11
11
|
# 2. Create Sauce Options object with the Browser Options object instance
|
12
|
-
sauce_options = SauceBindings::Options.
|
12
|
+
sauce_options = SauceBindings::Options.chrome(selenium_options: browser_options)
|
13
13
|
|
14
14
|
# 3. Create Session object with SauceOptions object instance
|
15
15
|
session = SauceBindings::Session.new(sauce_options)
|
@@ -3,11 +3,12 @@
|
|
3
3
|
require 'sauce_bindings'
|
4
4
|
require 'rspec'
|
5
5
|
|
6
|
-
describe '
|
6
|
+
describe 'Common Options' do
|
7
7
|
it 'creates session' do
|
8
|
-
# 1. Create
|
8
|
+
# 1. Create Options instance with common w3c options
|
9
9
|
sauce_options = SauceBindings::Options.firefox(browser_version: '88.0',
|
10
|
-
platform_name: 'Windows 8'
|
10
|
+
platform_name: 'Windows 8',
|
11
|
+
unhandled_prompt_behavior: 'ignore')
|
11
12
|
|
12
13
|
# 2. Create Session object with SauceOptions object instance
|
13
14
|
session = SauceBindings::Session.new(sauce_options)
|
@@ -7,7 +7,7 @@ describe 'Sauce Options' do
|
|
7
7
|
it 'creates session' do
|
8
8
|
# 1. Create a SauceOptions instance with Sauce Labs Specific Options
|
9
9
|
sauce_options = SauceBindings::Options.firefox(extended_debugging: true,
|
10
|
-
idle_timeout:
|
10
|
+
idle_timeout: 45,
|
11
11
|
time_zone: 'Alaska')
|
12
12
|
|
13
13
|
# 2. Create Session object with SauceOptions object instance
|