watirgrid 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/controller +1 -0
- data/bin/provider +1 -0
- data/examples/find_by_uuid.rb +28 -0
- data/examples/google.rb +19 -0
- data/examples/info.rb +14 -0
- data/examples/restart_firefox.rb +14 -0
- data/examples/simple.rb +7 -5
- data/lib/controller.rb +1 -1
- data/lib/provider.rb +94 -10
- data/lib/watirgrid.rb +15 -6
- data/spec/grid_spec.rb +31 -23
- data/spec/stub.rb +41 -0
- data/spec/tuples_spec.rb +46 -0
- data/spec/utilities_spec.rb +51 -0
- metadata +14 -2
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/90kts/watirgrid"
|
12
12
|
gem.authors = ["Tim Koopmans"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.version = "0.0.
|
14
|
+
gem.version = "0.0.5"
|
15
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
16
|
end
|
17
17
|
rescue LoadError
|
data/bin/controller
CHANGED
data/bin/provider
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require '../lib/watirgrid'
|
3
|
+
|
4
|
+
grid = Watir::Grid.new(:ring_server_port => 12358,
|
5
|
+
:ring_server_host => '192.168.1.102',
|
6
|
+
:loglevel => Logger::DEBUG)
|
7
|
+
grid.start(:read_all => true)
|
8
|
+
|
9
|
+
threads = []
|
10
|
+
grid.browsers.each do |browser|
|
11
|
+
threads << Thread.new do
|
12
|
+
@uuid = browser[:uuid]
|
13
|
+
p @uuid
|
14
|
+
end
|
15
|
+
end
|
16
|
+
threads.each {|thread| thread.join}
|
17
|
+
|
18
|
+
grid.start(:read_all => true, :uuid => @uuid)
|
19
|
+
|
20
|
+
threads = []
|
21
|
+
grid.browsers.each do |browser|
|
22
|
+
threads << Thread.new do
|
23
|
+
@uuid = browser[:uuid]
|
24
|
+
p @uuid
|
25
|
+
end
|
26
|
+
end
|
27
|
+
threads.each {|thread| thread.join}
|
28
|
+
|
data/examples/google.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require '../lib/watirgrid'
|
3
|
+
|
4
|
+
grid = Watir::Grid.new(:ring_server_port => 12358,
|
5
|
+
:ring_server_host => '184.73.224.146',
|
6
|
+
:loglevel => Logger::DEBUG)
|
7
|
+
grid.start(:read_all => true)
|
8
|
+
|
9
|
+
threads = []
|
10
|
+
grid.browsers.each do |browser|
|
11
|
+
threads << Thread.new do
|
12
|
+
b = browser[:object].new_browser
|
13
|
+
b.goto("http://google.com.au/")
|
14
|
+
b.text_field(:name, 'q').set("performance & test automation specialists")
|
15
|
+
sleep 1
|
16
|
+
b.button(:name, 'btnI').click
|
17
|
+
end
|
18
|
+
end
|
19
|
+
threads.each {|thread| thread.join}
|
data/examples/info.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require '../lib/watirgrid'
|
3
|
+
|
4
|
+
grid = Watir::Grid.new(:ring_server_port => 12358,
|
5
|
+
:ring_server_host => '192.168.1.102', :loglevel => Logger::DEBUG)
|
6
|
+
grid.start(:read_all => true)
|
7
|
+
|
8
|
+
threads = []
|
9
|
+
grid.browsers.each do |browser|
|
10
|
+
threads << Thread.new do
|
11
|
+
p browser
|
12
|
+
end
|
13
|
+
end
|
14
|
+
threads.each {|thread| thread.join}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require '../lib/watirgrid'
|
3
|
+
|
4
|
+
grid = Watir::Grid.new(:ring_server_port => 12358,
|
5
|
+
:ring_server_host => '192.168.1.102', :loglevel => Logger::DEBUG)
|
6
|
+
grid.start(:read_all => true)
|
7
|
+
|
8
|
+
threads = []
|
9
|
+
grid.browsers.each do |browser|
|
10
|
+
threads << Thread.new do
|
11
|
+
p browser
|
12
|
+
end
|
13
|
+
end
|
14
|
+
threads.each {|thread| thread.join}
|
data/examples/simple.rb
CHANGED
@@ -2,16 +2,18 @@ require 'rubygems'
|
|
2
2
|
require '../lib/watirgrid'
|
3
3
|
|
4
4
|
grid = Watir::Grid.new(:ring_server_port => 12358,
|
5
|
-
:ring_server_host => '192.168.1.
|
6
|
-
|
5
|
+
:ring_server_host => '192.168.1.102',
|
6
|
+
:loglevel => Logger::DEBUG)
|
7
|
+
grid.start(:read_all => true)
|
7
8
|
|
8
9
|
threads = []
|
9
10
|
grid.browsers.each do |browser|
|
10
11
|
threads << Thread.new do
|
11
12
|
b = browser[:object].new_browser
|
12
|
-
b.goto("http://
|
13
|
-
b.text_field(:name, '
|
14
|
-
|
13
|
+
b.goto("http://192.168.1.102:4567/")
|
14
|
+
b.text_field(:name, 'username').set("I am robot")
|
15
|
+
sleep 1
|
16
|
+
b.button(:id, 'go').click
|
15
17
|
end
|
16
18
|
end
|
17
19
|
threads.each {|thread| thread.join}
|
data/lib/controller.rb
CHANGED
@@ -94,7 +94,7 @@ class Controller
|
|
94
94
|
# Get the external facing interface for this server
|
95
95
|
def external_interface
|
96
96
|
begin
|
97
|
-
UDPSocket.open {|s| s.connect('
|
97
|
+
UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
|
98
98
|
rescue
|
99
99
|
'127.0.0.1'
|
100
100
|
end
|
data/lib/provider.rb
CHANGED
@@ -6,8 +6,8 @@ require 'rubygems'
|
|
6
6
|
require 'rinda/ring'
|
7
7
|
require 'rinda/tuplespace'
|
8
8
|
require 'logger'
|
9
|
-
require 'optparse'
|
10
9
|
require 'drb/acl'
|
10
|
+
require 'uuid'
|
11
11
|
|
12
12
|
begin
|
13
13
|
require 'watir'
|
@@ -15,16 +15,16 @@ rescue LoadError
|
|
15
15
|
end
|
16
16
|
|
17
17
|
begin
|
18
|
-
require '
|
18
|
+
require 'firewatir'
|
19
19
|
rescue LoadError
|
20
|
-
end
|
21
20
|
|
22
21
|
begin
|
23
|
-
require '
|
24
|
-
include FireWatir
|
22
|
+
require 'safariwatir'
|
25
23
|
rescue LoadError
|
26
24
|
end
|
27
25
|
|
26
|
+
end
|
27
|
+
|
28
28
|
module Watir
|
29
29
|
|
30
30
|
##
|
@@ -63,8 +63,91 @@ module Watir
|
|
63
63
|
else
|
64
64
|
@browser.new
|
65
65
|
end
|
66
|
-
end
|
67
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Get a list of running browsers (optionally specified by browser)
|
70
|
+
# 'iexplore','firefox','firefox-bin','chrome','safari','opera'
|
71
|
+
def get_running_browsers(browser=nil)
|
72
|
+
browsers = browser || \
|
73
|
+
['iexplore','firefox','firefox-bin','chrome','safari','opera']
|
74
|
+
case Config::CONFIG['arch']
|
75
|
+
when /mswin/
|
76
|
+
%x[tasklist].split(/\s+/).collect { |x| x[/\w+/]} \
|
77
|
+
& browsers.collect { |x| x.downcase }
|
78
|
+
when /linux|darwin/
|
79
|
+
%x[ps -A | grep -v ruby].split(/\/|\s+/).collect { |x| x.downcase} \
|
80
|
+
& browsers
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_running_processes
|
85
|
+
%x[ps -A | grep -v ruby].split(/\/|\s+/).collect.uniq
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Kill any browser running
|
90
|
+
def kill_all_browsers
|
91
|
+
case Config::CONFIG['arch']
|
92
|
+
when /mswin/
|
93
|
+
browsers = ['iexplore.exe', 'firefox.exe', 'chrome.exe']
|
94
|
+
browsers.each { |browser| %x[taskkill /F /IM #{browser}] }
|
95
|
+
when /linux/
|
96
|
+
browsers = ['firefox', 'chrome', 'opera']
|
97
|
+
browsers.each { |browser| %x[killall -r #{browser}] }
|
98
|
+
when /darwin/
|
99
|
+
browsers = ['firefox-bin', 'Chrome', 'Safari']
|
100
|
+
browsers.each { |browser| %x[killall -m #{browser}] }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Kill all browsers specified by browser name
|
106
|
+
# Windows: 'iexplore.exe', 'firefox.exe', 'chrome.exe'
|
107
|
+
# Linux: 'firefox', 'chrome', 'opera'
|
108
|
+
# OSX: 'firefox-bin', 'Chrome', 'Safari'
|
109
|
+
def kill_browser(browser)
|
110
|
+
case Config::CONFIG['arch']
|
111
|
+
when /mswin/
|
112
|
+
%x[taskkill /F /IM #{browser}]
|
113
|
+
when /linux/
|
114
|
+
%x[killall -r #{browser}]
|
115
|
+
when /darwin/
|
116
|
+
%x[killall -m #{browser}]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Start firefox (with an optional bin path) using the -jssh extension
|
122
|
+
def start_firefox_jssh(path=nil)
|
123
|
+
case Config::CONFIG['arch']
|
124
|
+
when /mswin/
|
125
|
+
bin = path || "C:/Program Files/Mozilla Firefox/firefox.exe"
|
126
|
+
when /linux/
|
127
|
+
bin = path || "/usr/bin/firefox"
|
128
|
+
when /darwin/
|
129
|
+
bin = path || "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
|
130
|
+
end
|
131
|
+
# fork off and die!
|
132
|
+
Thread.new {system(bin, "about:blank", "-jssh")}
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Get the logged-in user
|
137
|
+
def get_logged_in_user
|
138
|
+
%x[whoami].chomp
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Grep for a process (Linux/OSX-with-port only)
|
143
|
+
def process_grep(pattern)
|
144
|
+
%x[pgrep -l #{pattern}].split(/\n/)
|
145
|
+
end
|
146
|
+
|
147
|
+
def renew_provider
|
148
|
+
self.class.superclass
|
149
|
+
end
|
150
|
+
|
68
151
|
end
|
69
152
|
|
70
153
|
end
|
@@ -110,13 +193,14 @@ class Provider
|
|
110
193
|
|
111
194
|
# create a service tuple
|
112
195
|
@tuple = [
|
113
|
-
:
|
196
|
+
:WatirGrid,
|
114
197
|
:WatirProvider,
|
115
198
|
watir_provider,
|
116
199
|
'A watir provider',
|
117
200
|
hostname,
|
118
201
|
architecture,
|
119
|
-
@browser_type
|
202
|
+
@browser_type,
|
203
|
+
UUID.new.generate
|
120
204
|
]
|
121
205
|
|
122
206
|
# locate the Rinda Ring Server via a UDP broadcast
|
@@ -148,7 +232,7 @@ class Provider
|
|
148
232
|
# Get the external facing interface for this server
|
149
233
|
def external_interface
|
150
234
|
begin
|
151
|
-
UDPSocket.open {|s| s.connect('
|
235
|
+
UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
|
152
236
|
rescue
|
153
237
|
'127.0.0.1'
|
154
238
|
end
|
data/lib/watirgrid.rb
CHANGED
@@ -10,7 +10,7 @@ module Watir
|
|
10
10
|
# and instatiating remote browser objects on nominated providers.
|
11
11
|
class Grid
|
12
12
|
|
13
|
-
attr_accessor :drb_server_uri, :ring_server, :browsers
|
13
|
+
attr_accessor :drb_server_uri, :ring_server, :browsers, :tuples
|
14
14
|
|
15
15
|
def initialize(params = {})
|
16
16
|
@drb_server_host = params[:drb_server_host] || external_interface
|
@@ -41,6 +41,12 @@ module Watir
|
|
41
41
|
def size
|
42
42
|
@browsers.size
|
43
43
|
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Write tuple back to tuplespace when finished using it
|
47
|
+
def release_tuples
|
48
|
+
@tuples.each { |tuple| @ring_server.write(tuple) }
|
49
|
+
end
|
44
50
|
|
45
51
|
private
|
46
52
|
|
@@ -76,7 +82,7 @@ module Watir
|
|
76
82
|
# Get all tuple spaces on ringserver
|
77
83
|
def get_tuples(params = {})
|
78
84
|
quantity = calculate_quantity(params[:quantity])
|
79
|
-
read_tuples(params
|
85
|
+
read_tuples(params)
|
80
86
|
@log.info("Found #{@tuples.size} tuples.")
|
81
87
|
if @tuples.size > -1 then
|
82
88
|
@tuples[0..quantity].each do |tuple|
|
@@ -105,15 +111,17 @@ module Watir
|
|
105
111
|
##
|
106
112
|
# Read all tuples filtered by architecture and browser type
|
107
113
|
# then populate the tuples accessor
|
108
|
-
def read_tuples(
|
114
|
+
def read_tuples(params={})
|
109
115
|
@tuples = @ring_server.read_all([
|
110
|
-
:
|
116
|
+
:WatirGrid,
|
111
117
|
nil, # watir provider
|
112
118
|
nil, # browser front object
|
113
119
|
nil, # provider description
|
114
120
|
nil, # hostname
|
115
|
-
architecture,
|
116
|
-
browser_type]
|
121
|
+
params[:architecture],
|
122
|
+
params[:browser_type],
|
123
|
+
params[:uuid]
|
124
|
+
])
|
117
125
|
end
|
118
126
|
|
119
127
|
##
|
@@ -149,6 +157,7 @@ module Watir
|
|
149
157
|
tuple_hash[:hostname] = tuple[4]
|
150
158
|
tuple_hash[:architecture] = tuple[5]
|
151
159
|
tuple_hash[:browser_type] = tuple[6]
|
160
|
+
tuple_hash[:uuid] = tuple[7]
|
152
161
|
tuple_hash
|
153
162
|
end
|
154
163
|
|
data/spec/grid_spec.rb
CHANGED
@@ -15,31 +15,36 @@ describe 'WatirGrid' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should return how many grid are available in the tuplespace' do
|
18
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
18
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
19
|
+
:ring_server_host => '127.0.0.1')
|
19
20
|
grid.start(:read_all => true)
|
20
21
|
grid.size.should == 5
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'should read any 2 grid in the tuplespace' do
|
24
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
25
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
26
|
+
:ring_server_host => '127.0.0.1')
|
25
27
|
grid.start(:quantity => 2, :read_all => true)
|
26
28
|
grid.size.should == 2
|
27
29
|
end
|
28
30
|
|
29
31
|
it 'should take any 1 browser in the tuplespace' do
|
30
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
32
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
33
|
+
:ring_server_host => '127.0.0.1')
|
31
34
|
grid.start(:quantity => 1, :take_all => true)
|
32
35
|
grid.size.should == 1
|
33
36
|
end
|
34
37
|
|
35
38
|
it 'should take all grid remaining in tuplespace' do
|
36
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
39
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
40
|
+
:ring_server_host => '127.0.0.1')
|
37
41
|
grid.start(:take_all => true)
|
38
42
|
grid.size.should == 4
|
39
43
|
end
|
40
44
|
|
41
45
|
it 'should find no more grid in the tuplespace' do
|
42
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
46
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
47
|
+
:ring_server_host => '127.0.0.1')
|
43
48
|
grid.start(:read_all => true)
|
44
49
|
grid.size.should == 0
|
45
50
|
end
|
@@ -53,35 +58,40 @@ describe 'WatirGrid' do
|
|
53
58
|
end
|
54
59
|
|
55
60
|
it 'should take any 1 browser based on browser type' do
|
56
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
61
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
62
|
+
:ring_server_host => '127.0.0.1')
|
57
63
|
grid.start(:quantity => 1,
|
58
64
|
:take_all => true, :browser_type => 'safari')
|
59
65
|
grid.size.should == 1
|
60
66
|
end
|
61
67
|
|
62
68
|
it 'should fail to find any grid based on a specific browser type' do
|
63
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
69
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
70
|
+
:ring_server_host => '127.0.0.1')
|
64
71
|
grid.start(:quantity => 1,
|
65
72
|
:take_all => true, :browser_type => 'firefox')
|
66
73
|
grid.size.should == 0
|
67
74
|
end
|
68
75
|
|
69
76
|
it 'should fail to find any grid based on a unknown browser type' do
|
70
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
77
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
78
|
+
:ring_server_host => '127.0.0.1')
|
71
79
|
grid.start(:quantity => 1,
|
72
80
|
:take_all => true, :browser_type => 'penguin')
|
73
81
|
grid.size.should == 0
|
74
82
|
end
|
75
83
|
|
76
84
|
it 'should take any 1 browser based on specific architecture type' do
|
77
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
85
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
86
|
+
:ring_server_host => '127.0.0.1')
|
78
87
|
grid.start(:quantity => 1,
|
79
|
-
:take_all => true, :architecture => '
|
88
|
+
:take_all => true, :architecture => Config::CONFIG['arch'])
|
80
89
|
grid.size.should == 1
|
81
90
|
end
|
82
91
|
|
83
92
|
it 'should fail to find any grid based on unknown architecture type' do
|
84
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
93
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
94
|
+
:ring_server_host => '127.0.0.1')
|
85
95
|
grid.start(:quantity => 1,
|
86
96
|
:take_all => true, :architecture => 'geos-1992')
|
87
97
|
grid.size.should == 0
|
@@ -89,7 +99,8 @@ describe 'WatirGrid' do
|
|
89
99
|
|
90
100
|
it 'should take any 1 browser based on specific hostname' do
|
91
101
|
hostname = `hostname`.strip
|
92
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
102
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
103
|
+
:ring_server_host => '127.0.0.1')
|
93
104
|
grid.start(:quantity => 1,
|
94
105
|
:take_all => true,
|
95
106
|
:hostnames => { hostname => "127.0.0.1"}
|
@@ -98,15 +109,17 @@ describe 'WatirGrid' do
|
|
98
109
|
end
|
99
110
|
|
100
111
|
it 'should fail to find any grid based on unknown hostname' do
|
101
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
112
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
113
|
+
:ring_server_host => '127.0.0.1')
|
102
114
|
grid.start(:quantity => 1,
|
103
115
|
:take_all => true, :hostnames => {
|
104
116
|
"tokyo" => "127.0.0.1"})
|
105
117
|
grid.size.should == 0
|
106
118
|
end
|
107
|
-
|
119
|
+
|
108
120
|
it 'should take the last browser and execute some watir commands' do
|
109
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
121
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
122
|
+
:ring_server_host => '127.0.0.1')
|
110
123
|
grid.start(:quantity => 1, :take_all => true)
|
111
124
|
threads = []
|
112
125
|
grid.browsers.each do |browser|
|
@@ -124,17 +137,12 @@ describe 'WatirGrid' do
|
|
124
137
|
grid.size.should == 1
|
125
138
|
end
|
126
139
|
|
127
|
-
it 'should find no more
|
128
|
-
grid = Watir::Grid.new(:ring_server_port => 12351
|
140
|
+
it 'should find no more tuples in the tuplespace' do
|
141
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
142
|
+
:ring_server_host => '127.0.0.1')
|
129
143
|
grid.start(:read_all => true)
|
130
144
|
grid.size.should == 0
|
131
145
|
end
|
132
146
|
|
133
|
-
it 'should register a new browser on a remote provider' do
|
134
|
-
pending('provision of remote registration') do
|
135
|
-
grid.size.should == 0
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
147
|
end
|
140
148
|
|
data/spec/stub.rb
CHANGED
@@ -1,7 +1,48 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'sinatra'
|
3
|
+
require 'haml'
|
3
4
|
|
4
5
|
get '/load/:browser_id/:browser_object_id' do
|
5
6
|
params[:browser_object_id]
|
6
7
|
end
|
7
8
|
|
9
|
+
get '/' do
|
10
|
+
haml :example
|
11
|
+
end
|
12
|
+
|
13
|
+
post '/' do
|
14
|
+
"Congratulations #{params[:username]}, you hit the button!"
|
15
|
+
end
|
16
|
+
|
17
|
+
__END__
|
18
|
+
|
19
|
+
@@ layout
|
20
|
+
%html
|
21
|
+
= yield
|
22
|
+
|
23
|
+
@@ example
|
24
|
+
%style{:type=>"text/css"}
|
25
|
+
:plain
|
26
|
+
input {
|
27
|
+
border-bottom-style: inset;
|
28
|
+
border-bottom-width: 2px;
|
29
|
+
border-left-style: inset;
|
30
|
+
border-left-width: 2px;
|
31
|
+
border-right-style: inset;
|
32
|
+
border-right-width: 2px;
|
33
|
+
border-top-style: inset;
|
34
|
+
border-top-width: 2px;
|
35
|
+
font-family: arial, sans-serif;
|
36
|
+
font-size: 30px;
|
37
|
+
font-style: normal;
|
38
|
+
font-variant: normal;
|
39
|
+
font-weight: normal;
|
40
|
+
height: 40px;
|
41
|
+
width: 200px;
|
42
|
+
}
|
43
|
+
%form{:action=>'/', :method=>'POST'}
|
44
|
+
%input{:name=>'username', :value=>'username'}
|
45
|
+
%button{:id=>'go', :type=>'submit'} GO
|
46
|
+
|
47
|
+
|
48
|
+
|
data/spec/tuples_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe 'When taking tuples from the grid' do
|
4
|
+
before(:all) do
|
5
|
+
controller = Controller.new(
|
6
|
+
:ring_server_port => 12351,
|
7
|
+
:loglevel => Logger::ERROR)
|
8
|
+
controller.start
|
9
|
+
1.upto(5) do
|
10
|
+
provider = Provider.new(
|
11
|
+
:ring_server_port => 12351,
|
12
|
+
:loglevel => Logger::ERROR, :browser_type => 'safari')
|
13
|
+
provider.start
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should start 1st grid and take all tuples' do
|
18
|
+
grid1 = Watir::Grid.new(:ring_server_port => 12351,
|
19
|
+
:ring_server_host => '127.0.0.1')
|
20
|
+
grid1.start(:take_all => true)
|
21
|
+
grid1.size.should == 5
|
22
|
+
|
23
|
+
describe 'Then for subsequent grids' do
|
24
|
+
it 'should start 2nd grid and confirm there are no more tuples' do
|
25
|
+
grid2 = Watir::Grid.new(:ring_server_port => 12351,
|
26
|
+
:ring_server_host => '127.0.0.1')
|
27
|
+
grid2.start(:take_all => true)
|
28
|
+
grid2.size.should == 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should release the tuples taken by the 1st grid' do
|
32
|
+
grid1.release_tuples
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should start 3rd grid and confirm there are tuples available' do
|
36
|
+
grid3 = Watir::Grid.new(:ring_server_port => 12351,
|
37
|
+
:ring_server_host => '127.0.0.1')
|
38
|
+
grid3.start(:take_all => true)
|
39
|
+
grid3.size.should == 5
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe 'WatirGrid Utilities' do
|
4
|
+
before(:all) do
|
5
|
+
controller = Controller.new(
|
6
|
+
:ring_server_port => 12351,
|
7
|
+
:loglevel => Logger::ERROR)
|
8
|
+
controller.start
|
9
|
+
1.upto(1) do
|
10
|
+
provider = Provider.new(
|
11
|
+
:ring_server_port => 12351,
|
12
|
+
:loglevel => Logger::ERROR, :browser_type => 'safari')
|
13
|
+
provider.start
|
14
|
+
end
|
15
|
+
grid = Watir::Grid.new(:ring_server_port => 12351,
|
16
|
+
:ring_server_host => '127.0.0.1')
|
17
|
+
grid.start(:read_all => true)
|
18
|
+
@browser = grid.browsers[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should get the logged-in user for the remote provider' do
|
22
|
+
@browser[:object].get_logged_in_user.should == `whoami`.chomp
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should enumerate any running browsers on the remote provider' do
|
26
|
+
@browser[:object].get_running_browsers(['firefox-bin']).size.should == 0
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should be able to start a new firefox browser' do
|
30
|
+
@browser[:object].start_firefox_jssh
|
31
|
+
sleep 5
|
32
|
+
@browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should be able to kill all firefox browsers' do
|
36
|
+
@browser[:object].kill_browser('firefox-bin')
|
37
|
+
@browser[:object].get_running_browsers(['firefox-bin']).size.should == 0
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be able to start a new firefox browser specified by path' do
|
41
|
+
@browser[:object].start_firefox_jssh
|
42
|
+
("/Applications/Firefox.app/Contents/MacOS/firefox-bin")
|
43
|
+
sleep 5
|
44
|
+
@browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should be able to kill all browsers' do
|
48
|
+
@browser[:object].kill_all_browsers
|
49
|
+
@browser[:object].get_running_browsers.size.should == 0
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watirgrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Koopmans
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-03-02 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,10 @@ files:
|
|
42
42
|
- Rakefile
|
43
43
|
- bin/controller
|
44
44
|
- bin/provider
|
45
|
+
- examples/find_by_uuid.rb
|
46
|
+
- examples/google.rb
|
47
|
+
- examples/info.rb
|
48
|
+
- examples/restart_firefox.rb
|
45
49
|
- examples/simple.rb
|
46
50
|
- lib/controller.rb
|
47
51
|
- lib/provider.rb
|
@@ -50,6 +54,8 @@ files:
|
|
50
54
|
- spec/spec.opts
|
51
55
|
- spec/spec_helper.rb
|
52
56
|
- spec/stub.rb
|
57
|
+
- spec/tuples_spec.rb
|
58
|
+
- spec/utilities_spec.rb
|
53
59
|
- spec/watirgrid_spec.rb
|
54
60
|
- watirgrid.gemspec
|
55
61
|
has_rdoc: true
|
@@ -84,5 +90,11 @@ test_files:
|
|
84
90
|
- spec/grid_spec.rb
|
85
91
|
- spec/spec_helper.rb
|
86
92
|
- spec/stub.rb
|
93
|
+
- spec/tuples_spec.rb
|
94
|
+
- spec/utilities_spec.rb
|
87
95
|
- spec/watirgrid_spec.rb
|
96
|
+
- examples/find_by_uuid.rb
|
97
|
+
- examples/google.rb
|
98
|
+
- examples/info.rb
|
99
|
+
- examples/restart_firefox.rb
|
88
100
|
- examples/simple.rb
|