Selenium 1.0.4 → 1.0.9
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/lib/selenium.rb +1 -1
- data/lib/selenium/button.rb +1 -1
- data/lib/selenium/link.rb +2 -2
- data/lib/selenium/openqa/selenium-server.jar.txt +0 -0
- data/lib/selenium/openqa/selenium.rb +1509 -1334
- data/lib/selenium/openqa/sslSupport/cybervillainsCA.cer +0 -0
- data/lib/selenium/selenium_server.rb +2 -2
- data/lib/selenium/server.rb +91 -0
- data/lib/selenium/server_manager.rb +3 -81
- data/lib/selenium/version +1 -1
- data/spec/selenium/manual_tc_timout.rb +37 -0
- data/spec/selenium/tc_basic_operation.rb +12 -2
- data/spec/selenium/tc_domain_example.rb +59 -0
- data/spec/selenium/tc_interaction_example.rb +30 -0
- data/spec/selenium/{tc_selenium_server.rb → tc_server.rb} +6 -10
- data/spec/ts_selenium.rb +6 -0
- metadata +11 -4
|
Binary file
|
|
@@ -27,8 +27,8 @@ class SeleniumServer
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Starts the Selenium server. This does not return until the server is shutdown.
|
|
30
|
-
def start
|
|
31
|
-
SeleniumServer.run(['-port', port_number.to_s])
|
|
30
|
+
def start(*argv)
|
|
31
|
+
SeleniumServer.run(['-port', port_number.to_s] + argv)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# Stops the Selenium server
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module Selenium
|
|
2
|
+
# The class that can manages the server driver classes.
|
|
3
|
+
# This class is originally copied from the BuildMaster project.
|
|
4
|
+
# You can setup your build task to start the server before
|
|
5
|
+
# the tests and shutdown when it is finished
|
|
6
|
+
# server = Selenium::Server.new()
|
|
7
|
+
# begin
|
|
8
|
+
# server.start
|
|
9
|
+
# tests.run # run your tests here
|
|
10
|
+
# ensure
|
|
11
|
+
# server.stop
|
|
12
|
+
# end
|
|
13
|
+
class Server
|
|
14
|
+
# The status of the server. Values are
|
|
15
|
+
# * stopped
|
|
16
|
+
# * starting
|
|
17
|
+
# * started
|
|
18
|
+
# * stopping
|
|
19
|
+
# * error
|
|
20
|
+
attr_reader :status
|
|
21
|
+
|
|
22
|
+
def Server::on_port(port)
|
|
23
|
+
Server.new(SeleniumServer.new(port))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def initialize(server = SeleniumServer.new)
|
|
27
|
+
@server = server
|
|
28
|
+
@status = 'stopped'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Starts the server, returns when the server is up and running
|
|
32
|
+
def start(*argv)
|
|
33
|
+
starting_server(*argv)
|
|
34
|
+
wait_for_condition {@server.running?}
|
|
35
|
+
@status = 'started'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Starts the server, does not return until the server shuts down
|
|
39
|
+
def run(*argv)
|
|
40
|
+
@server.start(*argv)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Stops the server, returns when the server is no longer running
|
|
44
|
+
def stop
|
|
45
|
+
stopping_server
|
|
46
|
+
wait_for_condition {not @server.running?}
|
|
47
|
+
@status = 'stopped'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
def starting_server(*argv)
|
|
52
|
+
@status = 'starting'
|
|
53
|
+
['INT', 'TERM'].each { |signal|
|
|
54
|
+
trap(signal){ @server.stop}
|
|
55
|
+
}
|
|
56
|
+
start_thread {run(*argv)}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def stopping_server
|
|
60
|
+
@status = 'stopping'
|
|
61
|
+
start_thread {@server.stop}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def start_thread
|
|
65
|
+
Thread.new do
|
|
66
|
+
begin
|
|
67
|
+
yield
|
|
68
|
+
rescue Exception => exception
|
|
69
|
+
@exception = exception
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def wait_for_condition
|
|
75
|
+
count = 0
|
|
76
|
+
sleep 1
|
|
77
|
+
while not (result = yield)
|
|
78
|
+
if (@exception)
|
|
79
|
+
error = @exception
|
|
80
|
+
@exception = nil
|
|
81
|
+
@status = 'error'
|
|
82
|
+
raise error
|
|
83
|
+
end
|
|
84
|
+
count = count + 1
|
|
85
|
+
raise 'wait timed out' unless count < 10
|
|
86
|
+
sleep 1
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -1,86 +1,8 @@
|
|
|
1
1
|
module Selenium
|
|
2
|
-
# The class that can manages the server driver classes.
|
|
3
|
-
# This class is copied from the BuildMaster project.
|
|
4
|
-
# You can setup your build task to start the server before
|
|
5
|
-
# the tests and shutdown when it is finished
|
|
6
|
-
# manager = Selenium::ServerManager.new(Selenium::Server.new)
|
|
7
|
-
# begin
|
|
8
|
-
# manager.start
|
|
9
|
-
# tests.run # run your tests here
|
|
10
|
-
# ensure
|
|
11
|
-
# manager.stop
|
|
12
|
-
# end
|
|
13
|
-
class ServerManager
|
|
14
|
-
# The status of the server. Values are
|
|
15
|
-
# * stopped
|
|
16
|
-
# * starting
|
|
17
|
-
# * started
|
|
18
|
-
# * stopping
|
|
19
|
-
# * error
|
|
20
|
-
attr_reader :status
|
|
21
2
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def initialize(server = SeleniumServer.new)
|
|
27
|
-
@server = server
|
|
28
|
-
@status = 'stopped'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Starts the server, returns when the server is up and running
|
|
32
|
-
def start
|
|
33
|
-
starting_server
|
|
34
|
-
wait_for_condition {@server.running?}
|
|
35
|
-
@status = 'started'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Stops the server, returns when the server is no longer running
|
|
39
|
-
def stop
|
|
40
|
-
stopping_server
|
|
41
|
-
wait_for_condition {not @server.running?}
|
|
42
|
-
@status = 'stopped'
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
private
|
|
46
|
-
def starting_server
|
|
47
|
-
@status = 'starting'
|
|
48
|
-
['INT', 'TERM'].each { |signal|
|
|
49
|
-
trap(signal){ @server.stop}
|
|
50
|
-
}
|
|
51
|
-
start_thread {@server.start}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def stopping_server
|
|
55
|
-
@status = 'stopping'
|
|
56
|
-
start_thread {@server.stop}
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def start_thread
|
|
60
|
-
Thread.new do
|
|
61
|
-
begin
|
|
62
|
-
yield
|
|
63
|
-
rescue Exception => exception
|
|
64
|
-
@exception = exception
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def wait_for_condition
|
|
70
|
-
count = 0
|
|
71
|
-
sleep 1
|
|
72
|
-
while not (result = yield)
|
|
73
|
-
if (@exception)
|
|
74
|
-
error = @exception
|
|
75
|
-
@exception = nil
|
|
76
|
-
@status = 'error'
|
|
77
|
-
raise error
|
|
78
|
-
end
|
|
79
|
-
count = count + 1
|
|
80
|
-
raise 'wait timed out' unless count < 10
|
|
81
|
-
sleep 1
|
|
82
|
-
end
|
|
83
|
-
end
|
|
3
|
+
require 'server'
|
|
4
|
+
# Renamed to Server for simplicity
|
|
5
|
+
class ServerManager < Server
|
|
84
6
|
|
|
85
7
|
end
|
|
86
8
|
end
|
data/lib/selenium/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.9
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require "spec"
|
|
2
|
+
|
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
4
|
+
|
|
5
|
+
require 'selenium'
|
|
6
|
+
|
|
7
|
+
describe 'Time Out Control' do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
after(:each) do
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
it "should honor the time out argument" do
|
|
17
|
+
link_list=["http://www.myantel.net.mm",
|
|
18
|
+
"http://www.khitlunge.net.mm",
|
|
19
|
+
"http://www.mrtv4.net.mm",
|
|
20
|
+
"http://www.mpt.net.mm",
|
|
21
|
+
"http://www.yatanarponteleport.net.mm",
|
|
22
|
+
"http://www.net.mm",
|
|
23
|
+
"http://www.mwdtv.net.mm",
|
|
24
|
+
"http://ns1.net.mm",
|
|
25
|
+
"http://www.isy.net.mm",
|
|
26
|
+
"http://www.mptmail.net.mm",
|
|
27
|
+
"http://www.mrtv3.net.mm"
|
|
28
|
+
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
selenium=Selenium::SeleniumDriver.new("localhost",4444,"*chrome", link_list.first, 600000)
|
|
32
|
+
selenium.start
|
|
33
|
+
selenium.set_timeout(600000)
|
|
34
|
+
link_list.each {|url| selenium.open(url) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -10,12 +10,21 @@ module Selenium
|
|
|
10
10
|
describe 'basic operation with selenium' do
|
|
11
11
|
|
|
12
12
|
before do
|
|
13
|
-
|
|
13
|
+
port = 4567
|
|
14
|
+
@server = Selenium::Server.on_port(port)
|
|
15
|
+
@server.start
|
|
16
|
+
@browser = Selenium::SeleniumDriver.new("localhost", port, "*iexplore", "http://localhost:2000", 10000)
|
|
14
17
|
@browser.start
|
|
15
18
|
@browser.open('http://localhost:2000/index.html')
|
|
16
19
|
end
|
|
20
|
+
|
|
21
|
+
after do
|
|
22
|
+
@browser.stop
|
|
23
|
+
@server.stop
|
|
24
|
+
end
|
|
17
25
|
|
|
18
|
-
it 'click through menus' do
|
|
26
|
+
it 'should click through menus' do
|
|
27
|
+
=begin comment
|
|
19
28
|
#TEST START
|
|
20
29
|
page = HomePage.new(@browser)
|
|
21
30
|
page.menu.download_link.click_wait
|
|
@@ -26,6 +35,7 @@ describe 'basic operation with selenium' do
|
|
|
26
35
|
page = HomePage.new(@browser)
|
|
27
36
|
page.menu.license_link.go
|
|
28
37
|
#TEST END
|
|
38
|
+
=end comment
|
|
29
39
|
end
|
|
30
40
|
end
|
|
31
41
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
2
|
+
|
|
3
|
+
require 'spec'
|
|
4
|
+
require 'selenium'
|
|
5
|
+
|
|
6
|
+
#START GOOGLEHOME
|
|
7
|
+
class GoogleHomPage
|
|
8
|
+
include Selenium::Locator
|
|
9
|
+
attr_reader :browser
|
|
10
|
+
|
|
11
|
+
def GoogleHomPage::open(sel)
|
|
12
|
+
sel.open("http://www.google.com/webhp")
|
|
13
|
+
GoogleHomPage.new(sel)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(browser)
|
|
17
|
+
@browser = browser
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def title
|
|
21
|
+
browser.get_title
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def search_field
|
|
25
|
+
Selenium::TextField.new(browser, by_name('q'))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def search_button
|
|
29
|
+
Selenium::Button.new(browser, by_name('btnG'))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
#END GOOGLEHOME
|
|
34
|
+
|
|
35
|
+
context 'Test goole search' do
|
|
36
|
+
before do
|
|
37
|
+
port = 4567
|
|
38
|
+
@server = Selenium::Server.on_port(port)
|
|
39
|
+
@server.start
|
|
40
|
+
@sel = Selenium::SeleniumDriver.new("localhost", port, "*chrome", "http://www.google.com", 15000)
|
|
41
|
+
@sel.start
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
after do
|
|
45
|
+
@sel.stop
|
|
46
|
+
@server.stop
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#START DOMAIN
|
|
50
|
+
specify'searh hello world with google using docmain based script' do
|
|
51
|
+
page = GoogleHomPage.open(@sel)
|
|
52
|
+
page.search_field.type('hello world')
|
|
53
|
+
page.search_button.click_wait
|
|
54
|
+
page.title.should == 'hello world - Google Search'
|
|
55
|
+
page.search_field.value.should == 'hello world'
|
|
56
|
+
end
|
|
57
|
+
#END DOMAIN
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
2
|
+
|
|
3
|
+
#START INTERACTION
|
|
4
|
+
require 'spec'
|
|
5
|
+
require 'selenium'
|
|
6
|
+
|
|
7
|
+
context 'Test goole search' do
|
|
8
|
+
before do
|
|
9
|
+
port = 4567
|
|
10
|
+
@server = Selenium::Server.on_port(4567)
|
|
11
|
+
@server.start
|
|
12
|
+
@sel = Selenium::SeleniumDriver.new("localhost", port, "*chrome", "http://www.google.com", 15000)
|
|
13
|
+
@sel.start
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
after do
|
|
17
|
+
@sel.stop
|
|
18
|
+
@server.stop
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
specify'searh hello world with google using interaction based script' do
|
|
22
|
+
@sel.open("http://www.google.com")
|
|
23
|
+
@sel.type("q", "hello world")
|
|
24
|
+
@sel.click("btnG")
|
|
25
|
+
@sel.wait_for_page_to_load("5000")
|
|
26
|
+
@sel.get_title.should == 'hello world - Google Search'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
#END INTERACTION
|
|
@@ -5,23 +5,19 @@ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
|
|
5
5
|
require 'selenium'
|
|
6
6
|
|
|
7
7
|
module Selenium
|
|
8
|
-
describe '
|
|
9
|
-
it '
|
|
10
|
-
server =
|
|
11
|
-
puts 'starting server...'
|
|
8
|
+
describe 'server manager' do
|
|
9
|
+
it 'supports starting and stopping server on specified port' do
|
|
10
|
+
server = Server.on_port(4321)
|
|
12
11
|
server.start
|
|
13
12
|
server.status.should == "started"
|
|
14
|
-
puts 'stopping server...'
|
|
15
13
|
server.stop
|
|
16
14
|
server.status.should == "stopped"
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
it '
|
|
20
|
-
server =
|
|
21
|
-
server.start
|
|
22
|
-
server.status.should == "started"
|
|
17
|
+
it 'should support arguments through start method' do
|
|
18
|
+
server = Server.on_port(3333)
|
|
19
|
+
server.start('-timeout 800')
|
|
23
20
|
server.stop
|
|
24
|
-
server.status.should == "stopped"
|
|
25
21
|
end
|
|
26
22
|
end
|
|
27
23
|
|
data/spec/ts_selenium.rb
ADDED
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.
|
|
2
|
+
rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: Selenium
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 1.0.
|
|
7
|
-
date: 2008-
|
|
6
|
+
version: 1.0.9
|
|
7
|
+
date: 2008-05-18 00:00:00 -07:00
|
|
8
8
|
summary: A project that wraps selenium API into object-oriented testing style and packages it into a RubyGem.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -40,7 +40,10 @@ files:
|
|
|
40
40
|
- lib/selenium/openqa/README
|
|
41
41
|
- lib/selenium/openqa/selenium-server.jar.txt
|
|
42
42
|
- lib/selenium/openqa/selenium.rb
|
|
43
|
+
- lib/selenium/openqa/sslSupport
|
|
44
|
+
- lib/selenium/openqa/sslSupport/cybervillainsCA.cer
|
|
43
45
|
- lib/selenium/selenium_server.rb
|
|
46
|
+
- lib/selenium/server.rb
|
|
44
47
|
- lib/selenium/server_manager.rb
|
|
45
48
|
- lib/selenium/text_field.rb
|
|
46
49
|
- lib/selenium/version
|
|
@@ -50,10 +53,14 @@ files:
|
|
|
50
53
|
- spec/selenium/download_page.rb
|
|
51
54
|
- spec/selenium/home_page.rb
|
|
52
55
|
- spec/selenium/license_page.rb
|
|
56
|
+
- spec/selenium/manual_tc_timout.rb
|
|
53
57
|
- spec/selenium/menu.rb
|
|
54
58
|
- spec/selenium/selenium_ruby_page.rb
|
|
55
59
|
- spec/selenium/tc_basic_operation.rb
|
|
56
|
-
- spec/selenium/
|
|
60
|
+
- spec/selenium/tc_domain_example.rb
|
|
61
|
+
- spec/selenium/tc_interaction_example.rb
|
|
62
|
+
- spec/selenium/tc_server.rb
|
|
63
|
+
- spec/ts_selenium.rb
|
|
57
64
|
- README
|
|
58
65
|
test_files: []
|
|
59
66
|
|