selenium-connect 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/selenium-connect.rb +34 -1
- data/lib/selenium-connect/configuration.rb +1 -0
- data/lib/selenium-connect/rake.task +1 -2
- data/lib/selenium-connect/runner.rb +54 -22
- data/lib/selenium-connect/server.rb +9 -4
- data/selenium-connect.gemspec +1 -1
- data/spec/{basic_spec.rb → acceptance_spec.rb} +8 -6
- metadata +2 -3
- data/lib/selenium-connect/selenium-connect.rb +0 -33
data/lib/selenium-connect.rb
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
require 'selenium-webdriver'
|
2
|
-
require 'selenium-connect/selenium-connect'
|
3
2
|
require 'selenium-connect/configuration'
|
4
3
|
require 'selenium-connect/runner'
|
5
4
|
require 'selenium-connect/server'
|
5
|
+
|
6
|
+
module SeleniumConnect
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def configure
|
10
|
+
yield configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration = Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :server, :driver
|
18
|
+
|
19
|
+
def localhost?
|
20
|
+
@configuration.host == 'localhost'
|
21
|
+
end
|
22
|
+
|
23
|
+
def run
|
24
|
+
if localhost?
|
25
|
+
@server = Server.new(@configuration)
|
26
|
+
server.start
|
27
|
+
end
|
28
|
+
@driver = Runner.new(@configuration).driver
|
29
|
+
end
|
30
|
+
|
31
|
+
def finish
|
32
|
+
driver.quit
|
33
|
+
if localhost? then server.stop end
|
34
|
+
end
|
35
|
+
|
36
|
+
alias :start :run
|
37
|
+
alias :stop :finish
|
38
|
+
end
|
@@ -1,36 +1,68 @@
|
|
1
1
|
module SeleniumConnect
|
2
2
|
class Runner
|
3
|
-
|
3
|
+
class Firefox
|
4
|
+
attr_reader :config, :capabilities
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
set_profile
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def get_profile
|
14
|
+
if config.profile_path
|
15
|
+
Selenium::WebDriver::Firefox::Profile.new config.profile_path
|
16
|
+
elsif config.profile_name
|
17
|
+
Selenium::WebDriver::Firefox::Profile.from_name config.profile_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_profile
|
22
|
+
profile = get_profile
|
23
|
+
profile.assume_untrusted_certificate_issuer = false unless profile.nil?
|
24
|
+
@capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
|
25
|
+
end
|
26
|
+
|
27
|
+
end #Firefox
|
28
|
+
|
29
|
+
class InternetExplorer
|
30
|
+
end #InternetExplorer
|
31
|
+
end #Runner
|
32
|
+
end #SeleniumConnect
|
33
|
+
|
34
|
+
module SeleniumConnect
|
35
|
+
class Runner
|
36
|
+
attr_reader :driver, :config
|
37
|
+
|
38
|
+
def initialize(config)
|
39
|
+
@config = config
|
40
|
+
@driver = init_driver
|
8
41
|
end
|
9
42
|
|
10
43
|
private
|
11
44
|
|
12
45
|
def set_server_url
|
13
|
-
"http://#{
|
46
|
+
"http://#{config.host}:#{config.port}/wd/hub"
|
14
47
|
end
|
15
48
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
49
|
+
def init_driver
|
50
|
+
Selenium::WebDriver.for(
|
51
|
+
:remote,
|
52
|
+
:url => set_server_url,
|
53
|
+
:desired_capabilities => get_capabilities)
|
22
54
|
end
|
23
55
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
56
|
+
def get_capabilities
|
57
|
+
case config.browser
|
58
|
+
when "firefox"
|
59
|
+
Firefox.new(config).capabilities
|
60
|
+
when "ie"
|
61
|
+
InternetExplorer.new(config).capabilities
|
62
|
+
else
|
63
|
+
puts "No valid browser specified"
|
64
|
+
end
|
28
65
|
end
|
29
66
|
|
30
|
-
|
31
|
-
|
32
|
-
:url => set_server_url,
|
33
|
-
:desired_capabilities => set_profile)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
67
|
+
end #Runner
|
68
|
+
end #SeleniumConnect
|
@@ -24,11 +24,16 @@ module SeleniumConnect
|
|
24
24
|
"require 'selenium/rake/server_task'
|
25
25
|
|
26
26
|
Selenium::Rake::ServerTask.new(:server) do |t|
|
27
|
-
#{
|
28
|
-
|
27
|
+
#{
|
28
|
+
if configuration.jar
|
29
|
+
"t.jar = '#{configuration.jar}'"
|
30
|
+
else
|
31
|
+
"t.version = :latest"
|
32
|
+
end
|
33
|
+
}
|
29
34
|
t.background
|
30
|
-
t.log = '#{configuration.log
|
31
|
-
t.port = #{configuration.port
|
35
|
+
t.log = '#{configuration.log}'
|
36
|
+
t.port = #{configuration.port}
|
32
37
|
end"
|
33
38
|
end
|
34
39
|
|
data/selenium-connect.gemspec
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'selenium-connect'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "Acceptance Tests" do
|
4
4
|
|
5
|
-
let(:google)
|
5
|
+
let(:google) { Google.new(SeleniumConnect.start) }
|
6
|
+
let(:driver) { SeleniumConnect.start }
|
7
|
+
let(:quit) { SeleniumConnect.finish }
|
6
8
|
|
7
9
|
context "Common" do
|
8
10
|
it "logging", :wip => true do
|
@@ -21,7 +23,7 @@ describe SeleniumConnect do
|
|
21
23
|
SeleniumConnect.configure do end
|
22
24
|
google.visit
|
23
25
|
google.page_title.should include("Google")
|
24
|
-
|
26
|
+
quit
|
25
27
|
end
|
26
28
|
|
27
29
|
it "localhost" do
|
@@ -30,13 +32,13 @@ describe SeleniumConnect do
|
|
30
32
|
end
|
31
33
|
google.visit
|
32
34
|
google.page_title.should include("Google")
|
33
|
-
|
35
|
+
quit
|
34
36
|
end
|
35
37
|
|
36
|
-
it "profile name" do
|
38
|
+
it "profile name", :wip => true do
|
37
39
|
pending "requires machine setup to run, and need a public example"
|
38
40
|
SeleniumConnect.configure do |c|
|
39
|
-
c.profile_name = "
|
41
|
+
c.profile_name = "nt50_ic_egroup"
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -74,10 +74,9 @@ files:
|
|
74
74
|
- lib/selenium-connect/configuration.rb
|
75
75
|
- lib/selenium-connect/rake.task
|
76
76
|
- lib/selenium-connect/runner.rb
|
77
|
-
- lib/selenium-connect/selenium-connect.rb
|
78
77
|
- lib/selenium-connect/server.rb
|
79
78
|
- selenium-connect.gemspec
|
80
|
-
- spec/
|
79
|
+
- spec/acceptance_spec.rb
|
81
80
|
homepage: https://github.com/arrgyle/selenium-connect
|
82
81
|
licenses:
|
83
82
|
- MIT
|
@@ -1,33 +0,0 @@
|
|
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
|
-
@configuration.host == 'localhost'
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
if localhost?
|
20
|
-
@server = Server.new(@configuration)
|
21
|
-
server.start
|
22
|
-
end
|
23
|
-
@driver = Runner.new(@configuration).driver
|
24
|
-
end
|
25
|
-
|
26
|
-
def finish
|
27
|
-
driver.quit
|
28
|
-
if localhost? then server.stop end
|
29
|
-
end
|
30
|
-
|
31
|
-
alias :start :run
|
32
|
-
alias :stop :finish
|
33
|
-
end
|