RDee 0.1 → 0.2
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/ChangeLog +5 -1
- data/README.md +95 -7
- data/lib/rdee.rb +80 -0
- data/lib/rdee/browser_factory.rb +25 -10
- data/lib/rdee/version.rb +1 -1
- data/spec/lib/rd_spec.rb +13 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ee57a488781369377cdc08a2c8ef183d0d599ad
|
4
|
+
data.tar.gz: b93f7f13abec8499bd2b559bf719fb8a177a7ce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8535d8b60f972c6d1b52a97b4b0b3dcd6057672825e96f927c4ef1ee83fe20334ea90d2090a56f06a61100f9c32347239a940fe232822f57204b8b181fafc326
|
7
|
+
data.tar.gz: 4695865cee85acaa708296d9fd2ca3db5a6d36e5e4321f6e6e1a54a86d3ce5d2cc85575c937ad76feaf1df9614d62ccb0240d058821501f4b4a08df3c740d6e8
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,103 @@
|
|
1
|
-
#
|
1
|
+
# RDee
|
2
|
+
|
3
|
+
RDee is a gem that makes it easy to switch between different browsers when you are using
|
4
|
+
Selenium or Watir as your driver. You can also easily switch between running on a local
|
5
|
+
browser or a browser that is part of a Selenium Grid on on Sauce Labs.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
RDee was designed to make it easy for your tests to switch between different browsers. It
|
10
|
+
can select browsers that are running on your local machine or on a Selenium Grid. The way
|
11
|
+
you select a browser is by calling one of the following methods:
|
12
|
+
|
13
|
+
````ruby
|
14
|
+
RDee.selenium_browser(target = :firefox, options = {})
|
15
|
+
# or
|
16
|
+
RDee.watir_browser(target = :firefox, options = {})
|
17
|
+
````
|
18
|
+
|
19
|
+
These methods take two optional parameters. The first is the target browser. The second
|
20
|
+
is options that can be passed to that browser when it is started.
|
21
|
+
|
22
|
+
### Specifying the target browser
|
23
|
+
|
24
|
+
As we saw in the previous section, you can specify the target browser by passing a symbol
|
25
|
+
to the `selenium_browser` or `watir_browser` methods. The problem with this is that you
|
26
|
+
would have to change the code if you wanted to use a different browser. RDee has made
|
27
|
+
this simpler by allowing you to set the target browser using an environment variable.
|
28
|
+
The environment variable is named `RDEE_BROWSER`. A couple of typical usage patterns
|
29
|
+
are to set this in the `cucumber.yml` file for specific profiles or to simply set this
|
30
|
+
on the command-line when running the tests. Here is an example of a `cucumber.yml` file:
|
31
|
+
|
32
|
+
````yml
|
33
|
+
default: RDEE_BROWSER=firefox --format pretty --color
|
34
|
+
chrome: RDEE_BROWSER=chrome --format pretty --color
|
35
|
+
safari: RDEE_BROWSER=safari --format pretty --color
|
36
|
+
````
|
37
|
+
|
38
|
+
From the command-line you could simply do this:
|
39
|
+
|
40
|
+
````
|
41
|
+
RDEE_BROWSER=chrome bundle exec cucumber
|
42
|
+
````
|
43
|
+
|
44
|
+
The format of the target passed to the methods or set in the environment variable determines
|
45
|
+
what browser, version, and host os you get. The format follows the following pattern:
|
46
|
+
|
47
|
+
````
|
48
|
+
firefox30_win8
|
49
|
+
````
|
50
|
+
|
51
|
+
The first part of the target determines what browser to use. At the current time you can
|
52
|
+
specify `firefox`, `chrome`, `ie`, or `safari`. In the near future we will be supporting
|
53
|
+
mobile platforms so stay tuned.
|
54
|
+
|
55
|
+
Immediately following the browser is the version. This is optional and if you do not specify
|
56
|
+
it will select whatever version is available. It is up to you to make sure that the browser
|
57
|
+
and version combination are valid.
|
58
|
+
|
59
|
+
Following the version there is an underscore followed by the host os. This value is also
|
60
|
+
optional. Currently the following host os values are available:
|
61
|
+
|
62
|
+
| host | description |
|
63
|
+
| --- | --- |
|
64
|
+
| win81 | Windows 8.1 |
|
65
|
+
| win8 | Windows 8 |
|
66
|
+
| win7 | Windows 7 |
|
67
|
+
| winxp | Windows XP |
|
68
|
+
| snow_leopard | OS X 10.6 |
|
69
|
+
| mountain_lion | OS X 10.8 |
|
70
|
+
| mavricks | OS X 10.9 |
|
71
|
+
| linux | Linux |
|
72
|
+
|
73
|
+
The host os value is typically used when running the tests on a Selenium Grid. It is up to
|
74
|
+
you to ensure that the host and requested browser combination exist on your grid.
|
75
|
+
|
76
|
+
### Additional Configurations
|
77
|
+
|
78
|
+
Additional parameters can be set by calling the configure method on the RDee module. First
|
79
|
+
of all, you can set the `url` value. If the `url` is set RDee will attempt to make a remote
|
80
|
+
connect to the grid specified by the `url`. Additionaly you can specify whether it should
|
81
|
+
use a persistent http connection as well as specify additional parameters that should be
|
82
|
+
sent to a specific type of browser when it is used. Here are examples:
|
83
|
+
|
84
|
+
````ruby
|
85
|
+
RDee.configure do | config |
|
86
|
+
config.url = 'http://path.to.selenium.grid/wd/hub'
|
87
|
+
config.persistent_http = true
|
88
|
+
config.chrome_options = { :switches => %w[--disable-extensions]}
|
89
|
+
config.firefox_options = { :switches => %w[--disable-popups]}
|
90
|
+
config.ie_options = { :switches => %w[--disable-popups]}
|
91
|
+
config.safari_options = { :switches => %w[--disable-popups]}
|
92
|
+
end
|
93
|
+
````
|
2
94
|
|
3
|
-
TODO: Write a gem description
|
4
95
|
|
5
96
|
## Installation
|
6
97
|
|
7
98
|
Add this line to your application's Gemfile:
|
8
99
|
|
9
|
-
gem '
|
100
|
+
gem 'RDee'
|
10
101
|
|
11
102
|
And then execute:
|
12
103
|
|
@@ -14,11 +105,8 @@ And then execute:
|
|
14
105
|
|
15
106
|
Or install it yourself as:
|
16
107
|
|
17
|
-
$ gem install
|
18
|
-
|
19
|
-
## Usage
|
108
|
+
$ gem install RDee
|
20
109
|
|
21
|
-
TODO: Write usage instructions here
|
22
110
|
|
23
111
|
## Contributing
|
24
112
|
|
data/lib/rdee.rb
CHANGED
@@ -2,6 +2,86 @@ require 'rdee/version'
|
|
2
2
|
require 'rdee/browser_factory'
|
3
3
|
require 'rdee/target_parser'
|
4
4
|
|
5
|
+
#
|
6
|
+
# RDee was designed to make it easy for your tests to switch between different browsers. It
|
7
|
+
# can select browsers that are running on your local machine or on a Selenium Grid. The way
|
8
|
+
# you select a browser is by calling one of the following methods:
|
9
|
+
#
|
10
|
+
# @example Calling the RDee methods
|
11
|
+
# RDee.selenium_browser(target = :firefox, options = {})
|
12
|
+
# # or
|
13
|
+
# RDee.watir_browser(target = :firefox, options = {})
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# These methods take two optional parameters. The first is the target browser. The second
|
17
|
+
# is options that can be passed to that browser when it is started.
|
18
|
+
#
|
19
|
+
# You can specify the target browser by passing a symbol
|
20
|
+
# to the `selenium_browser` or `watir_browser` methods. The problem with this is that you
|
21
|
+
# would have to change the code if you wanted to use a different browser. RDee has made
|
22
|
+
# this simpler by allowing you to set the target browser using an environment variable.
|
23
|
+
# The environment variable is named `RDEE_BROWSER`. A couple of typical usage patterns
|
24
|
+
# are to set this in the `cucumber.yml` file for specific profiles or to simply set this
|
25
|
+
# on the command-line when running the tests. Here is an example of a `cucumber.yml` file:
|
26
|
+
#
|
27
|
+
# @example Setting RDEE_BROWSer environment variable in cucumber.yml
|
28
|
+
# default: RDEE_BROWSER=firefox --format pretty --color
|
29
|
+
# chrome: RDEE_BROWSER=chrome --format pretty --color
|
30
|
+
# safari: RDEE_BROWSER=safari --format pretty --color
|
31
|
+
#
|
32
|
+
# From the command-line you could simply do this:
|
33
|
+
#
|
34
|
+
# @example Setting the RDEE_BROWSER environment variable from command-line
|
35
|
+
# RDEE_BROWSER=chrome bundle exec cucumber
|
36
|
+
#
|
37
|
+
# The format of the target passed to the methods or set in the environment variable determines
|
38
|
+
# what browser, version, and host os you get. The format follows the following pattern:
|
39
|
+
#
|
40
|
+
# @example Format of the target browser
|
41
|
+
# firefox30_win8
|
42
|
+
#
|
43
|
+
#
|
44
|
+
# The first part of the target determines what browser to use. At the current time you can
|
45
|
+
# specify `firefox`, `chrome`, `ie`, or `safari`. In the near future we will be supporting
|
46
|
+
# mobile platforms so stay tuned.
|
47
|
+
#
|
48
|
+
# Immediately following the browser is the version. This is optional and if you do not specify
|
49
|
+
# it will select whatever version is available. It is up to you to make sure that the browser
|
50
|
+
# and version combination are valid.
|
51
|
+
#
|
52
|
+
# Following the version there is an underscore followed by the host os. This value is also
|
53
|
+
# optional. Currently the following host os values are available:
|
54
|
+
#
|
55
|
+
# | host | description |
|
56
|
+
# | ------------- | ----------- |
|
57
|
+
# | win81 | Windows 8.1 |
|
58
|
+
# | win8 | Windows 8 |
|
59
|
+
# | win7 | Windows 7 |
|
60
|
+
# | winxp | Windows XP |
|
61
|
+
# | snow_leopard | OS X 10.6 |
|
62
|
+
# | mountain_lion | OS X 10.8 |
|
63
|
+
# | mavricks | OS X 10.9 |
|
64
|
+
# | linux | Linux |
|
65
|
+
#
|
66
|
+
# The host os value is typically used when running the tests on a Selenium Grid. It is up to
|
67
|
+
# you to ensure that the host and requested browser combination exist on your grid.
|
68
|
+
#
|
69
|
+
# Additional parameters can be set by calling the configure method on the RDee module. First
|
70
|
+
# of all, you can set the `url` value. If the `url` is set RDee will attempt to make a remote
|
71
|
+
# connect to the grid specified by the `url`. Additionaly you can specify whether it should
|
72
|
+
# use a persistent http connection as well as specify additional parameters that should be
|
73
|
+
# sent to a specific type of browser when it is used. Here are examples:
|
74
|
+
#
|
75
|
+
# @example Setting parameters using configure
|
76
|
+
# RDee.configure do | config |
|
77
|
+
# config.url = 'http://path.to.selenium.grid/wd/hub'
|
78
|
+
# config.persistent_http = true
|
79
|
+
# config.chrome_options = { :switches => %w[--disable-extensions]}
|
80
|
+
# config.firefox_options = { :switches => %w[--disable-popups]}
|
81
|
+
# config.ie_options = { :switches => %w[--disable-popups]}
|
82
|
+
# config.safari_options = { :switches => %w[--disable-popups]}
|
83
|
+
# end
|
84
|
+
#
|
5
85
|
module RDee
|
6
86
|
|
7
87
|
def self.watir_browser(target = :firefox, options = {})
|
data/lib/rdee/browser_factory.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require_relative 'target_parser'
|
2
2
|
|
3
|
+
|
4
|
+
|
3
5
|
module RDee
|
6
|
+
class ConnectionError < StandardError
|
7
|
+
end
|
8
|
+
|
4
9
|
class BrowserFactory
|
5
10
|
include TargetParser
|
6
11
|
|
7
12
|
attr_accessor :url, :persistent_http, :chrome_options, :firefox_options,
|
8
|
-
:ie_options, :safari_options
|
13
|
+
:ie_options, :safari_options
|
9
14
|
|
10
15
|
def watir_browser(target, options)
|
11
16
|
platform, options = platform_and_options(target, options)
|
@@ -20,19 +25,29 @@ module RDee
|
|
20
25
|
private
|
21
26
|
|
22
27
|
def watir_browser_for(platform, options)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
begin
|
29
|
+
if options.empty?
|
30
|
+
Watir::Browser.new platform
|
31
|
+
else
|
32
|
+
Watir::Browser.new platform, options
|
33
|
+
end
|
34
|
+
rescue Exception => e
|
35
|
+
$stderr.puts e
|
36
|
+
raise RDee::ConnectionError, e
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
30
40
|
def selenium_browser_for(platform, options)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
41
|
+
begin
|
42
|
+
if options.empty?
|
43
|
+
Selenium::WebDriver.for platform
|
44
|
+
else
|
45
|
+
Selenium::WebDriver.for platform, options
|
46
|
+
end
|
47
|
+
rescue Exception => e
|
48
|
+
$stderr.puts e
|
49
|
+
raise RDee::ConnectionError, e
|
50
|
+
end
|
36
51
|
end
|
37
52
|
|
38
53
|
def platform_and_options(target, options)
|
data/lib/rdee/version.rb
CHANGED
data/spec/lib/rd_spec.rb
CHANGED
@@ -10,7 +10,12 @@ describe RDee do
|
|
10
10
|
expect(watir_browser).to receive(:new).with(:firefox)
|
11
11
|
RDee.watir_browser
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
it "should catch and print exceptions that occur when establishing a connection" do
|
15
|
+
expect(watir_browser).to receive(:new).and_raise(Exception, 'foo')
|
16
|
+
expect{ RDee.watir_browser }.to raise_error(RDee::ConnectionError, 'foo')
|
17
|
+
end
|
18
|
+
end
|
14
19
|
|
15
20
|
context "when getting a connection for Selenium" do
|
16
21
|
let(:selenium_browser) { Selenium::WebDriver }
|
@@ -19,7 +24,12 @@ describe RDee do
|
|
19
24
|
expect(selenium_browser).to receive(:for).with(:firefox)
|
20
25
|
RDee.selenium_browser
|
21
26
|
end
|
22
|
-
|
27
|
+
|
28
|
+
it "should catch and print exceptions that occur when establishing a connection" do
|
29
|
+
expect(selenium_browser).to receive(:for).and_raise(Exception, 'foo')
|
30
|
+
expect{ RDee.selenium_browser }.to raise_error(RDee::ConnectionError, 'foo')
|
31
|
+
end
|
32
|
+
end
|
23
33
|
|
24
34
|
context "when using common functionality" do
|
25
35
|
it "should use the BROWSER environment variable when present" do
|
@@ -70,6 +80,7 @@ describe RDee do
|
|
70
80
|
config.url = nil
|
71
81
|
end
|
72
82
|
end
|
83
|
+
|
73
84
|
end
|
74
85
|
|
75
86
|
context "when passing additional browser options" do
|
@@ -161,15 +172,5 @@ describe RDee do
|
|
161
172
|
end
|
162
173
|
end
|
163
174
|
|
164
|
-
it "should not allow opera_options when not using opera" do
|
165
|
-
RDee.configure do |config|
|
166
|
-
config.opera_options = {opera_options: 'option'}
|
167
|
-
end
|
168
|
-
expect(watir_browser).to receive(:new).with(:firefox)
|
169
|
-
RDee.watir_browser(:firefox)
|
170
|
-
RDee.configure do |config|
|
171
|
-
config.opera_options = nil
|
172
|
-
end
|
173
|
-
end
|
174
175
|
end
|
175
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RDee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey S. Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir-webdriver
|
@@ -174,3 +174,4 @@ test_files:
|
|
174
174
|
- spec/lib/target_parser_spec.rb
|
175
175
|
- spec/lib/targets_spec.rb
|
176
176
|
- spec/spec_helper.rb
|
177
|
+
has_rdoc:
|