selenium-connect 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +28 -0
- data/README.md +39 -0
- data/example.rb +12 -0
- data/lib/selenium-connect/configuration.rb +5 -0
- data/lib/selenium-connect/rake.task +9 -0
- data/lib/selenium-connect/runner.rb +39 -0
- data/lib/selenium-connect/selenium-connect.rb +36 -0
- data/lib/selenium-connect/server.rb +47 -0
- data/lib/selenium-connect.rb +5 -0
- data/selenium-connect.gemspec +18 -0
- metadata +92 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@selenium-server
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
selenium-connect (1.2.0)
|
5
|
+
rake
|
6
|
+
selenium-webdriver
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
childprocess (0.3.9)
|
12
|
+
ffi (~> 1.0, >= 1.0.11)
|
13
|
+
ffi (1.6.0)
|
14
|
+
multi_json (1.7.2)
|
15
|
+
rake (10.0.4)
|
16
|
+
rubyzip (0.9.9)
|
17
|
+
selenium-webdriver (2.31.0)
|
18
|
+
childprocess (>= 0.2.5)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
rubyzip
|
21
|
+
websocket (~> 1.0.4)
|
22
|
+
websocket (1.0.7)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
selenium-connect!
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#selenium-connect
|
2
|
+
===============
|
3
|
+
|
4
|
+
This library aims to make configuring and running your Selenium tests against a Selenium Server simple for both local and remote execution.
|
5
|
+
|
6
|
+
## Getting Started
|
7
|
+
```ruby
|
8
|
+
require 'selenium-connect'
|
9
|
+
|
10
|
+
SeleniumConnect.configure do |c|
|
11
|
+
c.host = "localhost"
|
12
|
+
c.port = "4444"
|
13
|
+
c.browser = "firefox"
|
14
|
+
c.profile_path = "#{Dir.pwd}/profiles/your_custom_firefox_profile"
|
15
|
+
end
|
16
|
+
|
17
|
+
@driver = SeleniumConnect.start
|
18
|
+
|
19
|
+
@driver.get "http://www.google.com"
|
20
|
+
|
21
|
+
SeleniumConnect.finish
|
22
|
+
```
|
23
|
+
|
24
|
+
## Helpful bits
|
25
|
+
|
26
|
+
### Selenium Actions
|
27
|
+
This library uses the Selenium WebDriver Remote Bridge actions. You can find them [here](http://www.ruby-doc.org/gems/docs/b/bbc-selenium-webdriver-1.17.0/Selenium/WebDriver/Remote/Bridge.html).
|
28
|
+
|
29
|
+
### Start
|
30
|
+
If host is set to "localhost", it will download the latest selenium-standalone-server.jar (unless it already has) and run it. Or, you can specify your own jar (if you have one you prefer to use). If no additional parameters are set, it will be exected in the background, with logging disabled. This functionality is driven using the [Selenium Rake Server Task](http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/Rake/ServerTask.html).
|
31
|
+
|
32
|
+
### Finish
|
33
|
+
Issues a quit command to the driver (and stops the local server if your host is set to "localhost").
|
34
|
+
|
35
|
+
### Support
|
36
|
+
Currently, Firefox solo & with a pre-fab custom profile is all that is supported. More coming soon!
|
37
|
+
|
38
|
+
### Versioning
|
39
|
+
This project loosely follows [Semantic Versioning](http://semver.org/).
|
data/example.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#browser type determines server type
|
2
|
+
#browser type determines config params
|
3
|
+
#initializer *should* be the same
|
4
|
+
|
5
|
+
module SeleniumConnect
|
6
|
+
class Runner
|
7
|
+
attr_reader :driver, :configuration
|
8
|
+
|
9
|
+
def initialize(configuration)
|
10
|
+
@configuration = configuration
|
11
|
+
set_sensible_defaults
|
12
|
+
@driver = initialize_selenium
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def set_sensible_defaults
|
18
|
+
configuration.host = "localhost" unless configuration.host
|
19
|
+
configuration.port = "4444" unless configuration.port
|
20
|
+
configuration.browser = "firefox" unless configuration.browser
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_profile
|
24
|
+
profile = Selenium::WebDriver::Firefox::Profile.new(configuration.profile_path)
|
25
|
+
profile.assume_untrusted_certificate_issuer = false
|
26
|
+
Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
|
27
|
+
end
|
28
|
+
|
29
|
+
def set_server_url
|
30
|
+
"http://#{configuration.host}:#{configuration.port}/wd/hub"
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize_selenium
|
34
|
+
Selenium::WebDriver::Remote::Bridge.new(
|
35
|
+
:url => set_server_url,
|
36
|
+
:desired_capabilities => set_profile)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module SeleniumConnect
|
2
|
+
extend self
|
3
|
+
|
4
|
+
def configure
|
5
|
+
yield configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def configuration
|
9
|
+
@configuration = Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :server, :driver
|
13
|
+
|
14
|
+
def localhost?
|
15
|
+
case @configuration.host
|
16
|
+
when "localhost" then true
|
17
|
+
else false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
if localhost?
|
23
|
+
@server = Server.new(@configuration)
|
24
|
+
server.start
|
25
|
+
end
|
26
|
+
@driver = Runner.new(@configuration).driver
|
27
|
+
end
|
28
|
+
|
29
|
+
def finish
|
30
|
+
driver.quit
|
31
|
+
if localhost? then server.stop end
|
32
|
+
end
|
33
|
+
|
34
|
+
alias :start :run
|
35
|
+
alias :stop :finish
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module SeleniumConnect
|
2
|
+
class Server
|
3
|
+
attr_reader :configuration
|
4
|
+
|
5
|
+
def initialize(configuration)
|
6
|
+
@configuration = configuration
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
rake "start"
|
11
|
+
end
|
12
|
+
|
13
|
+
def stop
|
14
|
+
rake "stop"
|
15
|
+
end
|
16
|
+
|
17
|
+
def restart
|
18
|
+
rake "restart"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def generate_rake_task
|
24
|
+
"require 'selenium/rake/server_task'
|
25
|
+
|
26
|
+
Selenium::Rake::ServerTask.new(:server) do |t|
|
27
|
+
#{"t.version = :latest" unless configuration.jar}
|
28
|
+
#{if configuration.jar then "t.jar = '#{configuration.jar}'" end}
|
29
|
+
t.background
|
30
|
+
t.log = #{configuration.log ? configuration.log : "false"}
|
31
|
+
t.port = #{configuration.port ? configuration.port : "4444"}
|
32
|
+
end"
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_rake_file
|
36
|
+
rake_file = File.join(File.dirname(File.expand_path(__FILE__)))
|
37
|
+
file = File.open(rake_file<<"/rake.task", "w")
|
38
|
+
file << generate_rake_task
|
39
|
+
file.close
|
40
|
+
return rake_file
|
41
|
+
end
|
42
|
+
|
43
|
+
def rake(task)
|
44
|
+
system "rake -f #{get_rake_file} server:#{task}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'selenium-connect'
|
3
|
+
s.version = '1.2.0'
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.authors = ['Dave Haeffner']
|
6
|
+
s.email = ['dave@arrgyle.com']
|
7
|
+
s.homepage = 'https://github.com/arrgyle/selenium-connect'
|
8
|
+
s.summary = 'A configurator and runner for your Selenium tests against local and remote Selenium Servers.'
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split($/)
|
12
|
+
s.require_paths = ['lib']
|
13
|
+
|
14
|
+
s.required_ruby_version = '>=1.9'
|
15
|
+
|
16
|
+
s.add_dependency 'selenium-webdriver'
|
17
|
+
s.add_dependency 'rake'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: selenium-connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dave Haeffner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: selenium-webdriver
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- dave@arrgyle.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .rvmrc
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- README.md
|
58
|
+
- example.rb
|
59
|
+
- lib/selenium-connect.rb
|
60
|
+
- lib/selenium-connect/configuration.rb
|
61
|
+
- lib/selenium-connect/rake.task
|
62
|
+
- lib/selenium-connect/runner.rb
|
63
|
+
- lib/selenium-connect/selenium-connect.rb
|
64
|
+
- lib/selenium-connect/server.rb
|
65
|
+
- selenium-connect.gemspec
|
66
|
+
homepage: https://github.com/arrgyle/selenium-connect
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.9'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.24
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: A configurator and runner for your Selenium tests against local and remote
|
91
|
+
Selenium Servers.
|
92
|
+
test_files: []
|