selenium-launcher 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Guardfile +1 -1
- data/README.txt +14 -11
- data/lib/selenium-launcher.rb +5 -5
- data/lib/selenium-launcher/browser.rb +1 -1
- data/lib/selenium-launcher/launcher.rb +2 -2
- data/lib/selenium-launcher/version.rb +1 -1
- data/spec/browser_spec.rb +4 -4
- data/spec/launcher_spec.rb +12 -10
- data/spec/selenium-connect_spec.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60547600d5b222f4397bd73d87a84d2a55685675
|
4
|
+
data.tar.gz: 4cd1ece048ae683e5f7e7d493cde1c376fcaf7bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a961633050e98d9700d8e33e4ab856a399966a88a8fb3388ff6f2a603f5255ca18d1712f87655c4cab1f13041ec1958ec24ec1012ddcb15831ec2c8eaa2d1d52
|
7
|
+
data.tar.gz: 96676a875187b351f944163f68a3b133f05af4b5c56cc95e5b004a1e36305b34ae402bc2270f8a3d45309a4ebb1f927115026751c3563e85a38f971dfdb52445
|
data/.gitignore
CHANGED
data/Guardfile
CHANGED
data/README.txt
CHANGED
@@ -4,42 +4,45 @@
|
|
4
4
|
|
5
5
|
selenium-launcher provides a simple way to configure Selenium and launch a browser.
|
6
6
|
|
7
|
-
Currently supported
|
7
|
+
Currently supported approaches include:
|
8
8
|
1. Local browser execution with browser drivers (for easier test authoring)
|
9
9
|
2. Remote execution (for a single node or a grid)
|
10
10
|
|
11
|
+
NOTE: selenium-launcher will return a Selenium WebDriver object.
|
12
|
+
|
11
13
|
== CONSIDERATIONS:
|
12
14
|
|
13
15
|
+ Will need to sort out the best way to handle browser driver downloads and configuration per OS. Will start by letting the user do the work and automate it later (in a separate gem).
|
14
16
|
+ Cloud execution will need to be added later, but that has additional considerations. So that will be deferred for now.
|
15
17
|
+ Mobile is also a consideration. Again, one to defer for now.
|
16
18
|
|
19
|
+
== INSTALL:
|
20
|
+
|
21
|
+
sudo gem install selenium-launcher
|
22
|
+
|
17
23
|
== USAGE:
|
18
24
|
|
19
25
|
=== Environment Variables
|
20
26
|
|
21
27
|
Configuration occurs through a small set of environment variables:
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
SE_HOST (e.g., 'grid', or nothing)
|
30
|
+
SE_HOST_URL (e.g., URL to Standalone Remote or Grid instance)
|
31
|
+
SE_BROWSER (e.g., 'chrome', 'firefox', 'internet-explorer', 'safari')
|
26
32
|
|
27
33
|
If these values are not set properly, a RuntimeError will be returned along with a helpful message.
|
28
34
|
|
29
|
-
|
30
|
-
selenium-launcher will return a Selenium WebDriver object.
|
31
|
-
|
32
35
|
=== Local
|
33
36
|
|
34
|
-
ENV['
|
37
|
+
ENV['SE_BROWSER'] = 'firefox'
|
35
38
|
driver = SeleniumLauncher.launch
|
36
39
|
driver.quit
|
37
40
|
|
38
41
|
=== Grid
|
39
42
|
|
40
|
-
ENV['
|
41
|
-
ENV['
|
42
|
-
ENV['
|
43
|
+
ENV['SE_BROWSER'] = 'firefox'
|
44
|
+
ENV['SE_HOST'] = 'grid'
|
45
|
+
ENV['SE_HOST_URL'] = 'http://localhost:4444/wd/hub'
|
43
46
|
driver = SeleniumLauncher.launch
|
44
47
|
driver.quit
|
45
48
|
|
data/lib/selenium-launcher.rb
CHANGED
@@ -16,18 +16,18 @@ module SeleniumLauncher
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
ERRORS = { NoBrowserSpecified: 'You need to specify a browser (e.g.,
|
20
|
-
NoGridURLSpecified: 'You need to specify a URL when using a Grid (e.g.,
|
19
|
+
ERRORS = { NoBrowserSpecified: 'You need to specify a browser (e.g., SE_BROWSER).',
|
20
|
+
NoGridURLSpecified: 'You need to specify a URL when using a Grid (e.g., SE_HOST_URL).' }
|
21
21
|
|
22
22
|
def browser_check
|
23
|
-
if ENV['
|
23
|
+
if ENV['SE_BROWSER'].nil?
|
24
24
|
raise ERRORS[:NoBrowserSpecified]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def grid_check
|
29
|
-
if ENV['
|
30
|
-
if ENV['
|
29
|
+
if ENV['SE_HOST'] == 'grid'
|
30
|
+
if ENV['SE_HOST_URL'].nil?
|
31
31
|
raise ERRORS[:NoGridURLSpecified]
|
32
32
|
end
|
33
33
|
end
|
@@ -18,11 +18,11 @@ module SeleniumLauncher
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def launch
|
21
|
-
case ENV['
|
21
|
+
case ENV['SE_HOST']
|
22
22
|
when 'grid'
|
23
23
|
::Selenium::WebDriver.for(
|
24
24
|
:remote,
|
25
|
-
url: ENV['
|
25
|
+
url: ENV['SE_HOST_URL'],
|
26
26
|
desired_capabilities: browser.capabilities)
|
27
27
|
else
|
28
28
|
::Selenium::WebDriver.for browser.name.to_sym
|
data/spec/browser_spec.rb
CHANGED
@@ -3,25 +3,25 @@ require_relative '../lib/selenium-launcher/browser'
|
|
3
3
|
describe 'Browser returns', :unit do
|
4
4
|
|
5
5
|
it 'Chrome' do
|
6
|
-
ENV['
|
6
|
+
ENV['SE_BROWSER'] = 'chrome'
|
7
7
|
browser = SeleniumLauncher::Browser.load
|
8
8
|
expect(browser.class).to eql SeleniumLauncher::Browser::Chrome
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'Firefox' do
|
12
|
-
ENV['
|
12
|
+
ENV['SE_BROWSER'] = 'firefox'
|
13
13
|
browser = SeleniumLauncher::Browser.load
|
14
14
|
expect(browser.class).to eql SeleniumLauncher::Browser::Firefox
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'Internet Explorer' do
|
18
|
-
ENV['
|
18
|
+
ENV['SE_BROWSER'] = 'internet-explorer'
|
19
19
|
browser = SeleniumLauncher::Browser.load
|
20
20
|
expect(browser.class).to eql SeleniumLauncher::Browser::InternetExplorer
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'Safari' do
|
24
|
-
ENV['
|
24
|
+
ENV['SE_BROWSER'] = 'safari'
|
25
25
|
browser = SeleniumLauncher::Browser.load
|
26
26
|
expect(browser.class).to eql SeleniumLauncher::Browser::Safari
|
27
27
|
end
|
data/spec/launcher_spec.rb
CHANGED
@@ -10,14 +10,14 @@ describe 'Launcher', :integration do
|
|
10
10
|
context '-> Localhost -> ' do
|
11
11
|
|
12
12
|
it 'Chrome' do
|
13
|
-
ENV['
|
13
|
+
ENV['SE_BROWSER'] = 'chrome'
|
14
14
|
@launcher = SeleniumLauncher::Launcher.new
|
15
15
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
16
16
|
expect(@launcher.driver.browser).to eql :chrome
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'Firefox' do
|
20
|
-
ENV['
|
20
|
+
ENV['SE_BROWSER'] = 'firefox'
|
21
21
|
@launcher = SeleniumLauncher::Launcher.new
|
22
22
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
23
23
|
expect(@launcher.driver.browser).to eql :firefox
|
@@ -25,14 +25,14 @@ describe 'Launcher', :integration do
|
|
25
25
|
|
26
26
|
it 'Internet Explorer' do
|
27
27
|
pending 'Windows OS required' unless OS.windows?
|
28
|
-
ENV['
|
28
|
+
ENV['SE_BROWSER'] = 'internet-explorer'
|
29
29
|
@launcher = SeleniumLauncher::Launcher.new
|
30
30
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
31
31
|
expect(@launcher.driver.browser).to eql :"internet-explorer"
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'Safari' do
|
35
|
-
ENV['
|
35
|
+
ENV['SE_BROWSER'] = 'safari'
|
36
36
|
@launcher = SeleniumLauncher::Launcher.new
|
37
37
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
38
38
|
expect(@launcher.driver.browser).to eql :safari
|
@@ -43,19 +43,21 @@ describe 'Launcher', :integration do
|
|
43
43
|
context '-> Grid -> ' do
|
44
44
|
|
45
45
|
before(:all) do
|
46
|
-
ENV['
|
47
|
-
ENV['
|
46
|
+
ENV['SE_HOST'] = 'grid'
|
47
|
+
ENV['SE_HOST_URL'] = 'http://localhost:4444/wd/hub'
|
48
|
+
# Start Selenium Standalone Server
|
49
|
+
# For help downloading, see https://github.com/tourdedave/selenium-prep
|
48
50
|
end
|
49
51
|
|
50
52
|
it 'Chrome' do
|
51
|
-
ENV['
|
53
|
+
ENV['SE_BROWSER'] = 'chrome'
|
52
54
|
@launcher = SeleniumLauncher::Launcher.new
|
53
55
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
54
56
|
expect(@launcher.driver.browser).to eql :chrome
|
55
57
|
end
|
56
58
|
|
57
59
|
it 'Firefox' do
|
58
|
-
ENV['
|
60
|
+
ENV['SE_BROWSER'] = 'firefox'
|
59
61
|
@launcher = SeleniumLauncher::Launcher.new
|
60
62
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
61
63
|
expect(@launcher.driver.browser).to eql :firefox
|
@@ -63,14 +65,14 @@ describe 'Launcher', :integration do
|
|
63
65
|
|
64
66
|
it 'Internet Explorer' do
|
65
67
|
pending 'Windows OS required' unless OS.windows?
|
66
|
-
ENV['
|
68
|
+
ENV['SE_BROWSER'] = 'internet-explorer'
|
67
69
|
@launcher = SeleniumLauncher::Launcher.new
|
68
70
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
69
71
|
expect(@launcher.driver.browser).to eql :"internet-explorer"
|
70
72
|
end
|
71
73
|
|
72
74
|
it 'Safari' do
|
73
|
-
ENV['
|
75
|
+
ENV['SE_BROWSER'] = 'safari'
|
74
76
|
@launcher = SeleniumLauncher::Launcher.new
|
75
77
|
expect(@launcher.driver.class).to eql Selenium::WebDriver::Driver
|
76
78
|
expect(@launcher.driver.browser).to eql :safari
|
@@ -3,7 +3,7 @@ require_relative '../lib/selenium-launcher'
|
|
3
3
|
describe 'Selenium Launcher', :acceptance do
|
4
4
|
|
5
5
|
it 'runs' do
|
6
|
-
ENV['
|
6
|
+
ENV['SE_BROWSER'] = 'firefox'
|
7
7
|
driver = SeleniumLauncher.launch
|
8
8
|
expect(driver.class).to eql Selenium::WebDriver::Driver
|
9
9
|
expect(driver.browser).to eql :firefox
|
@@ -13,23 +13,23 @@ describe 'Selenium Launcher', :acceptance do
|
|
13
13
|
context '-> Config Checker -> ' do
|
14
14
|
|
15
15
|
before(:each) do
|
16
|
-
ENV['
|
17
|
-
ENV['
|
18
|
-
ENV['
|
16
|
+
ENV['SE_BROWSER'] = nil
|
17
|
+
ENV['SE_HOST'] = nil
|
18
|
+
ENV['SE_HOST_URL'] = nil
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'no browser' do
|
22
22
|
expect { driver = SeleniumLauncher.launch }.to raise_error(
|
23
23
|
RuntimeError,
|
24
|
-
'You need to specify a browser (e.g.,
|
24
|
+
'You need to specify a browser (e.g., SE_BROWSER).')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'no Grid host URL' do
|
28
|
-
ENV['
|
29
|
-
ENV['
|
28
|
+
ENV['SE_BROWSER'] = 'firefox'
|
29
|
+
ENV['SE_HOST'] = 'grid'
|
30
30
|
expect { driver = SeleniumLauncher.launch }.to raise_error(
|
31
31
|
RuntimeError,
|
32
|
-
'You need to specify a URL when using a Grid (e.g.,
|
32
|
+
'You need to specify a URL when using a Grid (e.g., SE_HOST_URL).')
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium-launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Haeffner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|