saucelabs 0.5
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.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/ChangeLog +1 -0
- data/Gemfile +10 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +258 -0
- data/Rakefile +18 -0
- data/cucumber.yml +1 -0
- data/features/Example.feature +7 -0
- data/features/step_definitions/my_steps.rb +14 -0
- data/features/support/android/appium.txt +1 -0
- data/features/support/ios/appium.txt +1 -0
- data/lib/saucelabs.rb +53 -0
- data/lib/saucelabs/parsed_values.rb +129 -0
- data/lib/saucelabs/sauce_api.rb +29 -0
- data/lib/saucelabs/sauce_browser_factory.rb +122 -0
- data/saucelabs.gemspec +25 -0
- data/spec/lib/parsed_values_spec.rb +52 -0
- data/spec/lib/sauce_browser_factory_spec.rb +120 -0
- data/spec/lib/saucelabs_spec.rb +213 -0
- data/spec/spec_helper.rb +3 -0
- data/travis.yml +3 -0
- metadata +173 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/ChangeLog
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
=== Version 0.2
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Pradeep K. Macharla
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,258 @@
|
|
1
|
+
# SauceLabs
|
2
|
+
|
3
|
+
saucelabs gem is written in simple ruby so as to be able to set the desired capabilities and browser options for selenium/watir grid execution
|
4
|
+
and also be able to dynamically set the browser choice through an environment variable and execute the same scripts across browsers.The gem was
|
5
|
+
initially written to help connect to saucelabs, however the current version support local execution, selenium grid execution and execution against
|
6
|
+
Sauce Labs cloud environment. Please bear in mind that to execute against Sauce Labs cloud, you would require to register and get a username, password
|
7
|
+
to access Sauce Labs on their [website] (http://www.saucelabs.com)
|
8
|
+
Also platform and device parameters in the desired capabilities object when creating a connection to
|
9
|
+
Sauce Labs. It can also be used to create a connection to local browser instance in addition to Sauce Labs
|
10
|
+
The gem has been tested on MRI ruby and JRuby. Please report any issues and I will try my best to fix asap.
|
11
|
+
|
12
|
+
##Pre-Requisites
|
13
|
+
If you are planning to use a Selenium GRID or connect to Sauce Labs, it is assumed that you have an understanding on the Selenium GRID connection parameters. Sauce Labs works as a large Selenium GRID with username and password auth.
|
14
|
+
|
15
|
+
## Background
|
16
|
+
|
17
|
+
saucelabs gem is intended to be able to extract 4 main parameters viz. browser, version, platform and device
|
18
|
+
that gets set in the desired capabilities object. The gem creation got inspired by the below blog post
|
19
|
+
http://seleniumframework.wordpress.com/2014/05/18/pattern-for-running-multiple-cucumber-projects-on-ci-server/
|
20
|
+
Though the gem name is saucelabs , it can be used to create browser instances locally and against any selenium grid.
|
21
|
+
|
22
|
+
## Local Execution
|
23
|
+
|
24
|
+
````ruby
|
25
|
+
require 'saucelabs'
|
26
|
+
SauceLabs.watir_browser(browser = :firefox, browser_options = {})
|
27
|
+
# or
|
28
|
+
require 'saucelabs'
|
29
|
+
SauceLabs.selenium_driver(browser = :firefox, browser_options = {})
|
30
|
+
````
|
31
|
+
The methods use firefox as default browser and browser_options as optional parameter. You can specify other browsers
|
32
|
+
by the following:
|
33
|
+
|
34
|
+
````ruby
|
35
|
+
SauceLabs.watir_browser(browser = :chrome, browser_options = {})
|
36
|
+
# or
|
37
|
+
SauceLabs.selenium_driver(browser = :chrome, browser_options = {})
|
38
|
+
````
|
39
|
+
|
40
|
+
## Executing against local selenium grid
|
41
|
+
It is assumed that you have started the grid as per the page [Grid 2] (http://code.google.com/p/selenium/wiki/Grid2)
|
42
|
+
|
43
|
+
Another example of being able to use chrome 35 on Windows8 platform
|
44
|
+
|
45
|
+
````ruby
|
46
|
+
SauceLabs.watir_browser(browser = :'chrome35|windows8', browser_options = {:url => 'http://localhost:4444/wd/hub'})
|
47
|
+
# or
|
48
|
+
SauceLabs.selenium_driver(browser = :'chrome35|windows8', browser_options = {:url => 'http://localhost:4444/wd/hub'})
|
49
|
+
````
|
50
|
+
|
51
|
+
## Executing against Sauce Labs
|
52
|
+
|
53
|
+
Uses chrome 35 on Windows8 platform
|
54
|
+
|
55
|
+
````ruby
|
56
|
+
SauceLabs.watir_browser(browser = :'chrome35|windows8', browser_options = {:url => 'http://username:password@ip:port/wd/hub'})
|
57
|
+
# or
|
58
|
+
SauceLabs.selenium_driver(browser = :'chrome35|windows8', browser_options = {:url => 'http://username:password@ip:port/wd/hub'})
|
59
|
+
````
|
60
|
+
|
61
|
+
## More ways and parameters (using conf)
|
62
|
+
|
63
|
+
Another example of being able to use chrome 35 on Windows8 platform (The :url can also be set using SauceLabs.conf, see below)
|
64
|
+
|
65
|
+
````ruby
|
66
|
+
SauceLabs.watir_browser(browser = :'chrome35|windows8', browser_options = {})
|
67
|
+
# or
|
68
|
+
SauceLabs.selenium_driver(browser = :'chrome35|windows8', browser_options = {})
|
69
|
+
````
|
70
|
+
|
71
|
+
|
72
|
+
Yet Another example of being able to use chrome on mac platform and Android device (The :url needs to be set using SauceLabs.conf, see below)
|
73
|
+
|
74
|
+
````ruby
|
75
|
+
SauceLabs.watir_browser(browser = :'chrome|linux|android', browser_options = {})
|
76
|
+
# or
|
77
|
+
SauceLabs.selenium_driver(browser = :'chrome|linux|android', browser_options = {})
|
78
|
+
````
|
79
|
+
|
80
|
+
Yet Another example of being able to use safari on mac platform and iphone device (The :url needs to be set using SauceLabs.conf, see below)
|
81
|
+
|
82
|
+
````ruby
|
83
|
+
SauceLabs.watir_browser(browser = :'chrome|linux|iphone', browser_options = {})
|
84
|
+
# or
|
85
|
+
SauceLabs.selenium_driver(browser = :'chrome|linux|iphone', browser_options = {})
|
86
|
+
````
|
87
|
+
|
88
|
+
A simple ruby code example with watir and executing locally:
|
89
|
+
|
90
|
+
````ruby
|
91
|
+
require 'saucelabs'
|
92
|
+
include SauceLabs
|
93
|
+
|
94
|
+
ENV['BROWSER'] = "chrome"
|
95
|
+
@browser = SauceLabs.watir_browser
|
96
|
+
@browser.goto "http://www.google.com"
|
97
|
+
@browser.quit
|
98
|
+
````
|
99
|
+
|
100
|
+
A simple ruby code example with selenium and executing locally:
|
101
|
+
|
102
|
+
````ruby
|
103
|
+
require 'saucelabs'
|
104
|
+
include SauceLabs
|
105
|
+
|
106
|
+
ENV['BROWSER'] = "chrome"
|
107
|
+
@browser = SauceLabs.selenium_driver
|
108
|
+
@browser.navigate.to "http://www.google.com"
|
109
|
+
@browser.quit
|
110
|
+
````
|
111
|
+
|
112
|
+
A simple ruby code example with watir and executes against saucelabs:
|
113
|
+
|
114
|
+
````ruby
|
115
|
+
require 'saucelabs'
|
116
|
+
include SauceLabs
|
117
|
+
|
118
|
+
@browser = SauceLabs.watir_browser(:'chrome35|windows8', {:url => 'http://username:password@ip:port/wd/hub'})
|
119
|
+
@browser.goto "http://www.google.com"
|
120
|
+
@browser.quit
|
121
|
+
````
|
122
|
+
|
123
|
+
A simple ruby code example with watir and executes against local selenium grid:
|
124
|
+
It is assumed that you have started the grid as per the page [Grid 2] (http://code.google.com/p/selenium/wiki/Grid2)
|
125
|
+
|
126
|
+
````ruby
|
127
|
+
require 'saucelabs'
|
128
|
+
include SauceLabs
|
129
|
+
|
130
|
+
@browser = SauceLabs.watir_browser(:'chrome35|windows8', {:url => 'http://localhost:4444/wd/hub'})
|
131
|
+
@browser.goto "http://www.google.com"
|
132
|
+
@browser.quit
|
133
|
+
````
|
134
|
+
|
135
|
+
|
136
|
+
### Set BROWSER environment variable
|
137
|
+
|
138
|
+
In the above section, we have seen that it is very easy to set browser as a symbol
|
139
|
+
to the methods watir_browser and selenium_driver. However we would most likely want to dynamically set
|
140
|
+
the browser value. saucelabs reads from an environment variable 'BROWSER'. The following examples would help
|
141
|
+
understand the patterns. We can either use cucumber.yml file or set it on the command line as per your choice
|
142
|
+
|
143
|
+
````yml
|
144
|
+
default: BROWSER=firefox --format pretty --color
|
145
|
+
chrome: BROWSER=chrome --format pretty --color
|
146
|
+
ie: BROWSER=ie --format pretty --color
|
147
|
+
````
|
148
|
+
|
149
|
+
Execution from command line is simple too:
|
150
|
+
|
151
|
+
````
|
152
|
+
cucumber BROWSER=chrome features
|
153
|
+
````
|
154
|
+
|
155
|
+
The string pattern that is followed by this gem is as follows (Observer the '|' delimiter):
|
156
|
+
|
157
|
+
|
158
|
+
````
|
159
|
+
chrome36|win81
|
160
|
+
safari|linux|iphone
|
161
|
+
chrome|linux|android
|
162
|
+
````
|
163
|
+
|
164
|
+
Hence the following also applies:
|
165
|
+
|
166
|
+
````yml
|
167
|
+
default: BROWSER=chrome36|win81 --format pretty --color
|
168
|
+
safari_mac: BROWSER=safari|linux|iphone --format pretty --color
|
169
|
+
chrome_android: BROWSER=chrome|linux|android --format pretty --color
|
170
|
+
````
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
The first part determines the browser and its version
|
175
|
+
The second part determines the platform value that is set in capabilities object
|
176
|
+
The third part (used only for mobile device testing) determines the device
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
The following table is a mapping of all the platforms available on Sauce Labs website
|
181
|
+
|
182
|
+
| platform | description |
|
183
|
+
| --- | --- |
|
184
|
+
| windowsxp | Windows XP |
|
185
|
+
| osx109 | OS X 10.9 |
|
186
|
+
| osx106 | OS X 10.6 |
|
187
|
+
| osx108 | OS X 10.8 |
|
188
|
+
| linux | Linux |
|
189
|
+
| windows81 | Windows 8.1 |
|
190
|
+
| windows8 | Windows 8 |
|
191
|
+
| windows7 | Windows 7 |
|
192
|
+
|
193
|
+
The platform values can also be obtained from https://saucelabs.com/platforms
|
194
|
+
|
195
|
+
Additional platforms that are NOT on saucelabs however added to this gem to support selenium grid platforms
|
196
|
+
|
197
|
+
| platform | description |
|
198
|
+
| --- | --- |
|
199
|
+
| xp | XP|
|
200
|
+
| any | ANY |
|
201
|
+
| mac | MAC |
|
202
|
+
| unix | UNIX |
|
203
|
+
| vista | VISTA |
|
204
|
+
| windows | WINDOWS |
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
The following table is a mapping of all the devices available on Sauce Labs website
|
209
|
+
|
210
|
+
| device | description |
|
211
|
+
| --- | --- |
|
212
|
+
| iphone | iPhone |
|
213
|
+
| android | Android |
|
214
|
+
|
215
|
+
|
216
|
+
### Setting parameters using a block
|
217
|
+
|
218
|
+
We can also set parameters like sauce url, http_persistent and browser options. Below are some examples:
|
219
|
+
|
220
|
+
|
221
|
+
````ruby
|
222
|
+
SauceLabs.conf do | conf|
|
223
|
+
conf.url = 'http://username:password@ip:port/wd/hub' #Saucelabs connection url
|
224
|
+
conf.persistent_http = true
|
225
|
+
conf.browser_options = { :switches => %w[--disable-extensions],:chromeOptions => {"args" => ["test-type" ]}}
|
226
|
+
end
|
227
|
+
````
|
228
|
+
|
229
|
+
## Documentation
|
230
|
+
|
231
|
+
You can view the RDocs for this project [here] (http://rubydoc.info/github/machzqcq/saucelabs/master/frames).
|
232
|
+
|
233
|
+
## Installation
|
234
|
+
|
235
|
+
Add this line to your application's Gemfile:
|
236
|
+
|
237
|
+
gem 'saucelabs'
|
238
|
+
|
239
|
+
And then execute:
|
240
|
+
|
241
|
+
$ bundle install/update
|
242
|
+
|
243
|
+
Require the module:
|
244
|
+
|
245
|
+
require 'saucelabs'
|
246
|
+
|
247
|
+
Or install it yourself as:
|
248
|
+
|
249
|
+
$ gem install saucelabs
|
250
|
+
|
251
|
+
|
252
|
+
## Contributing
|
253
|
+
|
254
|
+
1. Fork it ( https://github.com/[my-github-username]/fork )
|
255
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
256
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
257
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
258
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
desc 'Run iOS tests'
|
9
|
+
task :ios do
|
10
|
+
Dir.chdir 'ios'
|
11
|
+
exec 'rspec'
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Run Android tests'
|
15
|
+
task :android do
|
16
|
+
Dir.chdir 'android'
|
17
|
+
exec 'rspec'
|
18
|
+
end
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --no-source --color --format pretty
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Feature: Using saucelabs gem to invoke a local browser instance
|
2
|
+
Scenario: launch chrome browser locally
|
3
|
+
When I invoke chrome browser
|
4
|
+
Then I hit google website
|
5
|
+
Scenario: launch chrome browser locally using environment variable
|
6
|
+
When I invoke chrome browser and set environment variable
|
7
|
+
Then I hit google website
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'saucelabs'
|
2
|
+
|
3
|
+
When(/^I invoke chrome browser$/) do
|
4
|
+
@browser = SauceLabs.selenium_driver(browser= :chrome)
|
5
|
+
end
|
6
|
+
|
7
|
+
Then(/^I hit google website$/) do
|
8
|
+
@browser.navigate.to "http://www.google.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
When(/^I invoke chrome browser and set environment variable$/) do
|
12
|
+
ENV['BROWSER']= "chrome"
|
13
|
+
@browser = SauceLabs.selenium_driver
|
14
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Android appium
|
@@ -0,0 +1 @@
|
|
1
|
+
Support for appium.txt
|
data/lib/saucelabs.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'saucelabs/sauce_browser_factory'
|
2
|
+
require 'saucelabs/parsed_values'
|
3
|
+
|
4
|
+
module SauceLabs
|
5
|
+
#attr_accessor :factory
|
6
|
+
|
7
|
+
#
|
8
|
+
# Creates a watir browser session and returns the browser object
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# SauceLabs.watir_browser(browser = :chrome, browser_options = {})
|
12
|
+
# @param [String] the browser string passed into the method
|
13
|
+
# @param [Hash] the optional hash to specify browser options
|
14
|
+
# @return [Object] browser session
|
15
|
+
#
|
16
|
+
|
17
|
+
def self.watir_browser(browser = :firefox, browser_options={})
|
18
|
+
factory.watir_browser(browser,browser_options)
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Creates a Selenium driver session and returns the driver object
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# SauceLabs.selenium_driver(browser = :chrome, browser_options = {})
|
26
|
+
# @param [String] the browser string passed into the method
|
27
|
+
# @param [Hash] the optional hash to specify browser options
|
28
|
+
# @return [Object] browser session
|
29
|
+
#
|
30
|
+
|
31
|
+
def self.selenium_driver(browser = :firefox, browser_options={})
|
32
|
+
factory.selenium_driver(browser,browser_options)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Yields to Factory object if parameters are set using conf
|
37
|
+
#
|
38
|
+
# @return [Object] browser session
|
39
|
+
#
|
40
|
+
|
41
|
+
def self.conf
|
42
|
+
yield factory
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def self.factory
|
48
|
+
@factory ||= SauceBrowserFactory.new
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
module SauceLabs
|
2
|
+
module ParsedValues
|
3
|
+
|
4
|
+
#
|
5
|
+
# Extracts browser, version, platform, device from the browser string
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# extract_values_from(:'safari5|linux|iphone') will extract
|
9
|
+
# browser = safari
|
10
|
+
# version=5
|
11
|
+
# platform=Linux
|
12
|
+
# device=iPhone
|
13
|
+
#
|
14
|
+
# @param [String] the browser string passed into the method
|
15
|
+
# @return [String,String,String,String] browser, version, platform and device
|
16
|
+
#
|
17
|
+
def extract_values_from(browser_string)
|
18
|
+
browser = extract_browser(browser_string).to_sym
|
19
|
+
version = extract_version(browser_string)
|
20
|
+
platform = extract_platform(browser_string)
|
21
|
+
device = extract_device(browser_string)
|
22
|
+
return browser,version,platform,device
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
#
|
28
|
+
# Extracts browser from browser string
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# extract_browser(:'safari5|linux|iphone') will extract
|
32
|
+
# browser = safari
|
33
|
+
#
|
34
|
+
# @param [String] the browser string passed into the method
|
35
|
+
# @return [String] the browser value
|
36
|
+
#
|
37
|
+
def extract_browser(value)
|
38
|
+
browser = value.to_s.split(/\d+/)[0]
|
39
|
+
browser = browser.to_s.split('|')[0] if browser.to_s.include? '|'
|
40
|
+
browser
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Extracts version from browser string
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# extract_version(:'safari5|linux|iphone') will extract
|
48
|
+
# browser = safari
|
49
|
+
#
|
50
|
+
# @param [String] the browser string passed into the method
|
51
|
+
# @return [String] the version value
|
52
|
+
#
|
53
|
+
def extract_version(value)
|
54
|
+
value = value.to_s.split('|')[0] if value.to_s.include? '|'
|
55
|
+
regexp_to_match = /\d{1,}/
|
56
|
+
if (not regexp_to_match.match(value).nil?)
|
57
|
+
version = regexp_to_match.match(value)[0]
|
58
|
+
else
|
59
|
+
version = ''
|
60
|
+
end
|
61
|
+
version
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Extracts platform from browser string
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# extract_platform(:'safari5|linux|iphone') will extract
|
69
|
+
# browser = safari
|
70
|
+
#
|
71
|
+
# @param [String] the browser string passed into the method
|
72
|
+
# @return [String] the platform value
|
73
|
+
#
|
74
|
+
def extract_platform(value)
|
75
|
+
platform = value.to_s.split('|')[1] if value.to_s.include? '|'
|
76
|
+
sauce_platforms
|
77
|
+
@sauce_platforms[platform] if not platform.nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Extracts device from browser string
|
82
|
+
#
|
83
|
+
# @example
|
84
|
+
# extract_device(:'safari5|linux|iphone') will extract
|
85
|
+
# browser = safari
|
86
|
+
#
|
87
|
+
# @param [String] the browser string passed into the method
|
88
|
+
# @return [String] the device value
|
89
|
+
#
|
90
|
+
|
91
|
+
def extract_device(value)
|
92
|
+
device = value.to_s.split('|')[2] if value.to_s.include? '|'
|
93
|
+
sauce_devices
|
94
|
+
@sauce_devices[device] if not device.nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Defines the platforms available on Sauce Labs as a Hash
|
99
|
+
|
100
|
+
def sauce_platforms
|
101
|
+
@sauce_platforms = Hash.new
|
102
|
+
@sauce_platforms["windowsxp"] = "Windows XP"
|
103
|
+
@sauce_platforms["osx109"] = "OS X 10.9"
|
104
|
+
@sauce_platforms["osx106"] = "OS X 10.6"
|
105
|
+
@sauce_platforms["osx108"] = "OS X 10.8"
|
106
|
+
@sauce_platforms["linux"] = "Linux"
|
107
|
+
@sauce_platforms["windows81"] = "Windows 8.1"
|
108
|
+
@sauce_platforms["windows8"] = "Windows 8"
|
109
|
+
@sauce_platforms["windows7"] = "Windows 7"
|
110
|
+
@sauce_platforms["any"] = "ANY"
|
111
|
+
@sauce_platforms["mac"] = "MAC"
|
112
|
+
@sauce_platforms["unix"] = "UNIX"
|
113
|
+
@sauce_platforms["vista"] = "VISTA"
|
114
|
+
@sauce_platforms["windows"] = "WINDOWS"
|
115
|
+
@sauce_platforms["xp"] = "XP"
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# Defines the devices available on Sauce Labs as a Hash
|
120
|
+
|
121
|
+
|
122
|
+
def sauce_devices
|
123
|
+
@sauce_devices = Hash.new
|
124
|
+
@sauce_devices["iphone"] = "iPhone"
|
125
|
+
@sauce_devices["android"] = "Android"
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "net/https"
|
3
|
+
|
4
|
+
module SauceLabs
|
5
|
+
module RestApiBuilder
|
6
|
+
|
7
|
+
def post(body)
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def puts(body)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(url)
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(url)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def sauce_credentials
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative 'parsed_values'
|
2
|
+
require 'selenium-webdriver'
|
3
|
+
require 'watir-webdriver'
|
4
|
+
|
5
|
+
module SauceLabs
|
6
|
+
#
|
7
|
+
# This class has the code necessary to create an instance of browser after making a connection to saucelabs.
|
8
|
+
# This class can also be used to create browser instance for local connections
|
9
|
+
#
|
10
|
+
class SauceBrowserFactory
|
11
|
+
include ParsedValues
|
12
|
+
|
13
|
+
attr_accessor :url,:options,:persistent_http
|
14
|
+
|
15
|
+
#
|
16
|
+
# Creates a watir browser session and returns the browser object
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# SauceLabs.watir_browser(browser = :chrome, browser_options = {})
|
20
|
+
# @param [String] the browser string passed into the method
|
21
|
+
# @param [Hash] the optional hash to specify browser options
|
22
|
+
# @return [Object] browser session
|
23
|
+
#
|
24
|
+
|
25
|
+
def watir_browser(browser,browser_options)
|
26
|
+
target,options = browser_caps(browser,browser_options)
|
27
|
+
create_watir_browser(target,options)
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Creates a Selenium driver session and returns the driver object
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# SauceLabs.selenium_driver(browser = :chrome, browser_options = {})
|
35
|
+
# @param [String] the browser string passed into the method
|
36
|
+
# @param [Hash] the optional hash to specify browser options
|
37
|
+
# @return [Object] browser session
|
38
|
+
#
|
39
|
+
|
40
|
+
def selenium_driver(browser,browser_options)
|
41
|
+
target,options = browser_caps(browser,browser_options)
|
42
|
+
create_selenium_driver(target,options)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
#def capybara_driver(browser,browser_options)
|
47
|
+
#Capybara.register_driver :selenium do |app|
|
48
|
+
#Capybara::Selenium::Driver.new(app, :browser => browser)
|
49
|
+
#end
|
50
|
+
#Capybara.default_driver = :selenium
|
51
|
+
#target,options = browser_caps(browser,browser_options)
|
52
|
+
#create_selenium_driver(target,options)
|
53
|
+
#end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def create_watir_browser(target,options)
|
58
|
+
if options.empty?
|
59
|
+
Watir::Browser.new target
|
60
|
+
else
|
61
|
+
Watir::Browser.new target,options
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_selenium_driver(target,options)
|
66
|
+
if options.empty?
|
67
|
+
Selenium::WebDriver.for target
|
68
|
+
else
|
69
|
+
Selenium::WebDriver.for target,options
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Returns the target and options including the capabilities
|
75
|
+
#
|
76
|
+
# @param [String] the browser string passed into the method
|
77
|
+
# @param [Hash] the optional hash to specify browser options
|
78
|
+
# @return [Symbol,Hash] browser as symbol and options as Hash
|
79
|
+
#
|
80
|
+
|
81
|
+
def browser_caps(browser,browser_options)
|
82
|
+
target = (browser.to_sym if ENV['BROWSER'].nil? or ENV['browser'].empty?) || (ENV['BROWSER'].to_sym)
|
83
|
+
browser,version,platform,device = extract_values_from(target)
|
84
|
+
options = {}
|
85
|
+
options.merge! browser_options
|
86
|
+
caps = capabilities(browser,version,platform,device)
|
87
|
+
options[:url] = url if url
|
88
|
+
if options.include? :url
|
89
|
+
browser = :remote
|
90
|
+
options[:desired_capabilities] = caps
|
91
|
+
end
|
92
|
+
options[:http_client] = http_client if persistent_http or options.delete(:persistent_http)
|
93
|
+
return browser,options
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def capabilities(browser, version, platform,device={})
|
98
|
+
capabilities = Selenium::WebDriver::Remote::Capabilities.send browser
|
99
|
+
capabilities.version = version unless version.nil? or version.empty?
|
100
|
+
capabilities.platform = platform unless platform.nil? or platform.empty?
|
101
|
+
capabilities.device = device unless device.nil? or device.empty?
|
102
|
+
capabilities
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# Returns a persistent http connection object
|
107
|
+
#
|
108
|
+
# @return [Object] Persistent http connection object
|
109
|
+
#
|
110
|
+
|
111
|
+
def http_client
|
112
|
+
client = Selenium::WebDriver::Remote::Http::Persistent.new
|
113
|
+
#client.proxy_uri="http://abc"
|
114
|
+
#client.read_timeout = 180
|
115
|
+
#client.socket_options = {}
|
116
|
+
client
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
data/saucelabs.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "saucelabs"
|
7
|
+
spec.version = "0.5"
|
8
|
+
spec.authors = ["Pradeep K. Macharla"]
|
9
|
+
spec.email = ["pradeep@seleniumframework.com"]
|
10
|
+
spec.summary = %q{Access saucelabs, selenium grid or local browser instance using simple ruby.}
|
11
|
+
spec.description = %q{Access saucelabs by passing browser, version, platform and device information}
|
12
|
+
spec.homepage = "https://github.com/machzqcq/saucelabs"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency 'watir-webdriver', '>= 0.6.9'
|
20
|
+
spec.add_dependency 'selenium-webdriver'
|
21
|
+
spec.add_dependency 'net-http-persistent'
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestParsedValues
|
4
|
+
include SauceLabs::ParsedValues
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
describe SauceLabs::ParsedValues do
|
9
|
+
|
10
|
+
let(:parsed_values) { TestParsedValues.new }
|
11
|
+
|
12
|
+
it "should extract browser name" do
|
13
|
+
browser, version, platform,device = parsed_values.extract_values_from(:chrome)
|
14
|
+
expect(browser).to eql :chrome
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should extract browser name if browser and version are specified" do
|
18
|
+
browser, version, platform,device = parsed_values.extract_values_from(:chrome35)
|
19
|
+
expect(browser).to eql :chrome
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should extract version if version is specified along with browser" do
|
23
|
+
browser,version,platform,device = parsed_values.extract_values_from(:chrome35)
|
24
|
+
expect(version).to eql '35'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should extract platform if platform is specified along with browser" do
|
28
|
+
browser, version, platform,device = parsed_values.extract_values_from(:'chrome35|windows81')
|
29
|
+
expect(platform).to eql 'Windows 8.1'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should extract iphone device if iphone is specified along with platform and browser" do
|
33
|
+
browser, version, platform,device = parsed_values.extract_values_from(:'chrome35|windows81|iphone')
|
34
|
+
expect(device).to eql 'iPhone'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should extract android device if android is specified along with platform and browser" do
|
38
|
+
browser, version, platform,device = parsed_values.extract_values_from(:'chrome35|windows81|android')
|
39
|
+
expect(device).to eql 'Android'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should report platform nil if platform is not defined in sauce_platforms" do
|
43
|
+
browser, version, platform,device = parsed_values.extract_values_from(:'chrome35|windows82|android')
|
44
|
+
expect(platform).to be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should report device nil if device is not defined in sauce_devices" do
|
48
|
+
browser, version, platform,device = parsed_values.extract_values_from(:'chrome35|windows82|xyz')
|
49
|
+
expect(device).to be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'selenium/webdriver/remote/http/persistent'
|
3
|
+
|
4
|
+
describe SauceLabs do
|
5
|
+
|
6
|
+
let(:watir_browser) { Watir::Browser }
|
7
|
+
|
8
|
+
context "Create Watir browser" do
|
9
|
+
it "should create a firefox instance if none specified" do
|
10
|
+
expect(watir_browser).to receive(:new).with(:firefox)
|
11
|
+
SauceLabs.watir_browser
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should create a chrome instance if chrome specified" do
|
15
|
+
expect(watir_browser).to receive(:new).with(:chrome)
|
16
|
+
SauceLabs.watir_browser(:chrome)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create a ie instance if ie specified" do
|
20
|
+
expect(watir_browser).to receive(:new).with(:ie)
|
21
|
+
SauceLabs.watir_browser(:ie)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "Create Selenium driver" do
|
26
|
+
let(:selenium_driver) { Selenium::WebDriver }
|
27
|
+
|
28
|
+
it "should create a firefox instance if non specified" do
|
29
|
+
expect(selenium_driver).to receive(:for).with(:firefox)
|
30
|
+
SauceLabs.selenium_driver
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create a chrome instance if chrome specified" do
|
34
|
+
expect(selenium_driver).to receive(:for).with(:chrome)
|
35
|
+
SauceLabs.selenium_driver(:chrome)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should create a ie instance if ie specified" do
|
39
|
+
expect(selenium_driver).to receive(:for).with(:ie)
|
40
|
+
SauceLabs.selenium_driver(:ie)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
context "Using an environment variable BROWSER" do
|
46
|
+
it "uses ENV['BROWSER'] if available" do
|
47
|
+
ENV['BROWSER'] = 'chrome'
|
48
|
+
expect(watir_browser).to receive(:new).with(:chrome)
|
49
|
+
SauceLabs.watir_browser
|
50
|
+
ENV.delete 'BROWSER'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should provide option to use http client for watir" do
|
54
|
+
client = double('http_client')
|
55
|
+
expect(Selenium::WebDriver::Remote::Http::Persistent).to receive(:new).and_return(client)
|
56
|
+
expect(watir_browser).to receive(:new).with(:firefox, http_client: client)
|
57
|
+
SauceLabs.watir_browser(:firefox, persistent_http: true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should provide option to use http_client via conf" do
|
61
|
+
SauceLabs.conf do |conf|
|
62
|
+
conf.persistent_http = true
|
63
|
+
end
|
64
|
+
client = double('http_client')
|
65
|
+
expect(Selenium::WebDriver::Remote::Http::Persistent).to receive(:new).and_return(client)
|
66
|
+
expect(watir_browser).to receive(:new).with(:firefox, http_client: client)
|
67
|
+
SauceLabs.watir_browser(:firefox)
|
68
|
+
SauceLabs.conf do |conf|
|
69
|
+
conf.persistent_http = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should provide to use sauce labs url using conf" do
|
74
|
+
SauceLabs.conf do |conf|
|
75
|
+
conf.url = 'http://username:password@ip:port/wd/hub'
|
76
|
+
end
|
77
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
78
|
+
SauceLabs.watir_browser(:firefox)
|
79
|
+
SauceLabs.conf do |conf|
|
80
|
+
conf.url = nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
context "can pass browser options" do
|
85
|
+
it "should provide to be able to pass firefox browser options" do
|
86
|
+
SauceLabs.conf do |conf|
|
87
|
+
conf.options = {options: 'blah'}
|
88
|
+
end
|
89
|
+
expect(watir_browser).to receive(:new).with(:firefox)
|
90
|
+
SauceLabs.watir_browser(:firefox)
|
91
|
+
SauceLabs.conf do |conf|
|
92
|
+
conf.options = nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should provide to be able to pass chrome browser options" do
|
97
|
+
SauceLabs.conf do |conf|
|
98
|
+
conf.options = {options: 'blah'}
|
99
|
+
end
|
100
|
+
expect(watir_browser).to receive(:new).with(:chrome)
|
101
|
+
SauceLabs.watir_browser(:chrome)
|
102
|
+
SauceLabs.conf do |conf|
|
103
|
+
conf.options = nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should provide to be able to pass ie browser options" do
|
108
|
+
SauceLabs.conf do |conf|
|
109
|
+
conf.options = {options: 'blah'}
|
110
|
+
end
|
111
|
+
expect(watir_browser).to receive(:new).with(:ie)
|
112
|
+
SauceLabs.watir_browser(:ie)
|
113
|
+
SauceLabs.conf do |conf|
|
114
|
+
conf.options = nil
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Example browser, platform and device combinations" do
|
4
|
+
|
5
|
+
let(:watir_browser) { Watir::Browser }
|
6
|
+
let(:selenium_driver) { Selenium::WebDriver}
|
7
|
+
let(:capabilities) { Selenium::WebDriver::Remote::Capabilities }
|
8
|
+
let(:desired_capabilities) { double('capabilities') }
|
9
|
+
|
10
|
+
context "Firefox" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
allow(capabilities).to receive(:firefox).and_return(desired_capabilities)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "allows Firefox with no version specified" do
|
17
|
+
expect(watir_browser).to receive(:new).with(:firefox)
|
18
|
+
SauceLabs.watir_browser :firefox
|
19
|
+
end
|
20
|
+
|
21
|
+
it "allows Firefox 3" do
|
22
|
+
expect(desired_capabilities).to receive(:version=).with('3')
|
23
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
24
|
+
SauceLabs.watir_browser :firefox3, url: 'http://username:password@ip:port/wd/hub'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "allows Firefox 6" do
|
28
|
+
expect(desired_capabilities).to receive(:version=).with('6')
|
29
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
30
|
+
SauceLabs.watir_browser :firefox6, url: 'http://username:password@ip:port/wd/hub'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "allows Firefox 10" do
|
34
|
+
expect(desired_capabilities).to receive(:version=).with('10')
|
35
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
36
|
+
SauceLabs.watir_browser :firefox10, url: 'http://username:password@ip:port/wd/hub'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "allows Firefox 25" do
|
40
|
+
expect(desired_capabilities).to receive(:version=).with('25')
|
41
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
42
|
+
SauceLabs.watir_browser :firefox25, url: 'http://username:password@ip:port/wd/hub'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "allows Firefox 28" do
|
46
|
+
expect(desired_capabilities).to receive(:version=).with('28')
|
47
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
48
|
+
SauceLabs.watir_browser :firefox28, url: 'http://username:password@ip:port/wd/hub'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "allows Firefox 29" do
|
52
|
+
expect(desired_capabilities).to receive(:version=).with('29')
|
53
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
54
|
+
SauceLabs.watir_browser :firefox29, url: 'http://username:password@ip:port/wd/hub'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "allows Firefox 30" do
|
58
|
+
expect(desired_capabilities).to receive(:version=).with('30')
|
59
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
60
|
+
SauceLabs.watir_browser :firefox30, url: 'http://username:password@ip:port/wd/hub'
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "Chrome" do
|
66
|
+
|
67
|
+
before(:each) do
|
68
|
+
allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "allows Chrome with no version specified" do
|
72
|
+
expect(watir_browser).to receive(:new).with(:chrome)
|
73
|
+
SauceLabs.watir_browser :chrome
|
74
|
+
end
|
75
|
+
|
76
|
+
it "allows Chrome 26" do
|
77
|
+
expect(desired_capabilities).to receive(:version=).with('26')
|
78
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
79
|
+
SauceLabs.watir_browser :chrome26, url: 'http://username:password@ip:port/wd/hub'
|
80
|
+
end
|
81
|
+
|
82
|
+
it "allows Chrome 27" do
|
83
|
+
expect(desired_capabilities).to receive(:version=).with('27')
|
84
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
85
|
+
SauceLabs.watir_browser :chrome27, url: 'http://username:password@ip:port/wd/hub'
|
86
|
+
end
|
87
|
+
|
88
|
+
it "allows Chrome 28" do
|
89
|
+
expect(desired_capabilities).to receive(:version=).with('28')
|
90
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
91
|
+
SauceLabs.watir_browser :chrome28, url: 'http://username:password@ip:port/wd/hub'
|
92
|
+
end
|
93
|
+
|
94
|
+
it "allows Chrome 29" do
|
95
|
+
expect(desired_capabilities).to receive(:version=).with('29')
|
96
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
97
|
+
SauceLabs.watir_browser :chrome29, url: 'http://username:password@ip:port/wd/hub'
|
98
|
+
end
|
99
|
+
|
100
|
+
it "allows Chrome 30" do
|
101
|
+
expect(desired_capabilities).to receive(:version=).with('30')
|
102
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
103
|
+
SauceLabs.watir_browser :chrome30, url: 'http://username:password@ip:port/wd/hub'
|
104
|
+
end
|
105
|
+
|
106
|
+
it "allows Chrome 32" do
|
107
|
+
expect(desired_capabilities).to receive(:version=).with('32')
|
108
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
109
|
+
SauceLabs.watir_browser :chrome32, url: 'http://username:password@ip:port/wd/hub'
|
110
|
+
end
|
111
|
+
|
112
|
+
it "allows Chrome 36" do
|
113
|
+
expect(desired_capabilities).to receive(:version=).with('36')
|
114
|
+
expect(watir_browser).to receive(:new).with(:remote, url: 'http://username:password@ip:port/wd/hub', desired_capabilities: anything())
|
115
|
+
SauceLabs.watir_browser :chrome36, url: 'http://username:password@ip:port/wd/hub'
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
context "Platforms Windows" do
|
120
|
+
before(:each) do
|
121
|
+
allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "extracts Windows XP" do
|
125
|
+
expect(desired_capabilities).to receive(:version=).with('26')
|
126
|
+
expect(desired_capabilities).to receive(:platform=).with('Windows XP')
|
127
|
+
expect(watir_browser).to receive(:new)
|
128
|
+
SauceLabs.watir_browser :'chrome26|windowsxp', url: 'http://username:password@ip:port/wd/hub'
|
129
|
+
end
|
130
|
+
|
131
|
+
it "extracts Windows 8.1" do
|
132
|
+
expect(desired_capabilities).to receive(:version=).with('35')
|
133
|
+
expect(desired_capabilities).to receive(:platform=).with('Windows 8.1')
|
134
|
+
expect(watir_browser).to receive(:new)
|
135
|
+
SauceLabs.watir_browser :'chrome35|windows81', url: 'http://username:password@ip:port/wd/hub'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "extracts Windows 7" do
|
139
|
+
expect(desired_capabilities).to receive(:version=).with('33')
|
140
|
+
expect(desired_capabilities).to receive(:platform=).with('Windows 7')
|
141
|
+
expect(watir_browser).to receive(:new)
|
142
|
+
SauceLabs.watir_browser :'chrome33|windows7', url: 'http://username:password@ip:port/wd/hub'
|
143
|
+
end
|
144
|
+
|
145
|
+
it "extracts Windows 8" do
|
146
|
+
expect(desired_capabilities).to receive(:version=).with('36')
|
147
|
+
expect(desired_capabilities).to receive(:platform=).with('Windows 8')
|
148
|
+
expect(watir_browser).to receive(:new)
|
149
|
+
SauceLabs.watir_browser :'chrome36|windows8', url: 'http://username:password@ip:port/wd/hub'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
context "Platforms OS X" do
|
155
|
+
before(:each) do
|
156
|
+
allow(capabilities).to receive(:safari).and_return(desired_capabilities)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "extracts OS X 10.9" do
|
160
|
+
expect(desired_capabilities).to receive(:version=).with('7')
|
161
|
+
expect(desired_capabilities).to receive(:platform=).with('OS X 10.9')
|
162
|
+
expect(watir_browser).to receive(:new)
|
163
|
+
SauceLabs.watir_browser :'safari7|osx109', url: 'http://username:password@ip:port/wd/hub'
|
164
|
+
end
|
165
|
+
|
166
|
+
it "extracts OS X 10.6" do
|
167
|
+
expect(desired_capabilities).to receive(:version=).with('6')
|
168
|
+
expect(desired_capabilities).to receive(:platform=).with('OS X 10.6')
|
169
|
+
expect(watir_browser).to receive(:new)
|
170
|
+
SauceLabs.watir_browser :'safari6|osx106', url: 'http://username:password@ip:port/wd/hub'
|
171
|
+
end
|
172
|
+
|
173
|
+
it "extracts OS X 10.8" do
|
174
|
+
expect(desired_capabilities).to receive(:version=).with('5')
|
175
|
+
expect(desired_capabilities).to receive(:platform=).with('OS X 10.8')
|
176
|
+
expect(watir_browser).to receive(:new)
|
177
|
+
SauceLabs.watir_browser :'safari5|osx108', url: 'http://username:password@ip:port/wd/hub'
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
context "Platforms Linux" do
|
183
|
+
before(:each) do
|
184
|
+
allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
|
185
|
+
end
|
186
|
+
|
187
|
+
it "extracts Linux" do
|
188
|
+
expect(desired_capabilities).to receive(:version=).with('36')
|
189
|
+
expect(desired_capabilities).to receive(:platform=).with('Linux')
|
190
|
+
expect(watir_browser).to receive(:new)
|
191
|
+
SauceLabs.watir_browser :'chrome36|linux', url: 'http://username:password@ip:port/wd/hub'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "Extract device" do
|
196
|
+
it "extracts iPhone" do
|
197
|
+
allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
|
198
|
+
expect(desired_capabilities).to receive(:platform=).with('Linux')
|
199
|
+
expect(desired_capabilities).to receive(:device=).with('iPhone')
|
200
|
+
expect(watir_browser).to receive(:new)
|
201
|
+
SauceLabs.watir_browser :'chrome|linux|iphone', url: 'http://username:password@ip:port/wd/hub'
|
202
|
+
end
|
203
|
+
|
204
|
+
it "extracts Android" do
|
205
|
+
allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
|
206
|
+
expect(desired_capabilities).to receive(:platform=).with('Linux')
|
207
|
+
expect(desired_capabilities).to receive(:device=).with('Android')
|
208
|
+
expect(selenium_driver).to receive(:for)
|
209
|
+
SauceLabs.selenium_driver :'chrome|linux|android', url: 'http://username:password@ip:port/wd/hub'
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/travis.yml
ADDED
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: saucelabs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.5'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pradeep K. Macharla
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: watir-webdriver
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.6.9
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.9
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: selenium-webdriver
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :runtime
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: net-http-persistent
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
none: false
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
none: false
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
none: false
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
none: false
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
none: false
|
92
|
+
prerelease: false
|
93
|
+
type: :development
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
none: false
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
none: false
|
108
|
+
prerelease: false
|
109
|
+
type: :development
|
110
|
+
description: Access saucelabs by passing browser, version, platform and device information
|
111
|
+
email:
|
112
|
+
- pradeep@seleniumframework.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- ChangeLog
|
120
|
+
- Gemfile
|
121
|
+
- Guardfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- cucumber.yml
|
126
|
+
- features/Example.feature
|
127
|
+
- features/step_definitions/my_steps.rb
|
128
|
+
- features/support/android/appium.txt
|
129
|
+
- features/support/ios/appium.txt
|
130
|
+
- lib/saucelabs.rb
|
131
|
+
- lib/saucelabs/parsed_values.rb
|
132
|
+
- lib/saucelabs/sauce_api.rb
|
133
|
+
- lib/saucelabs/sauce_browser_factory.rb
|
134
|
+
- saucelabs.gemspec
|
135
|
+
- spec/lib/parsed_values_spec.rb
|
136
|
+
- spec/lib/sauce_browser_factory_spec.rb
|
137
|
+
- spec/lib/saucelabs_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- travis.yml
|
140
|
+
homepage: https://github.com/machzqcq/saucelabs
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
none: false
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
none: false
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 1.8.24
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: Access saucelabs, selenium grid or local browser instance using simple ruby.
|
165
|
+
test_files:
|
166
|
+
- features/Example.feature
|
167
|
+
- features/step_definitions/my_steps.rb
|
168
|
+
- features/support/android/appium.txt
|
169
|
+
- features/support/ios/appium.txt
|
170
|
+
- spec/lib/parsed_values_spec.rb
|
171
|
+
- spec/lib/sauce_browser_factory_spec.rb
|
172
|
+
- spec/lib/saucelabs_spec.rb
|
173
|
+
- spec/spec_helper.rb
|