watirgrid 1.1.3.pre → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,27 +7,41 @@ To install WatirGrid:
7
7
  gem install watirgrid
8
8
 
9
9
  === The Basics
10
- WatirGrid is built on Rinda which implements the Linda distributed computing paradigm in Ruby. According to Wikipedia: “Linda is a model of coordination and communication among several parallel processes operating upon objects stored in and retrieved from shared, virtual, associative memory.”
11
10
 
12
- In other words, WatirGrid allows multiple parallel processes to *_provide_* remote Watir objects in the form of tuple spaces across a grid network. This grid network is *_controlled_* by a ring server.
11
+ WatirGrid allows a local client to control remote Watir objects in parallel, hosted by *providers* on a grid network, via a central *controller*.
13
12
 
14
13
  ==== Key Terminology
15
- The *controller* implements a repository of tuples (tuple space) that can be accessed concurrently. The controller also hosts a *ring* *server* which advertises these tuples across a grid network making it loosely coupled. Typically you will host one controller on a central machine. You will normally connect to this controller via a direct URI. You can also find this controller by its ring server, using a UDP broadcast for the ring server port.
14
+ The *controller* implements a repository of tuples (tuple space) that can be accessed concurrently. The controller also hosts a *ring* *server* which advertises these tuples across a grid network making it loosely coupled.
15
+
16
+ Typically you will host one controller on a central machine. You will normally connect to this controller via a contoller_uri. You can also find this controller by its ring server, using a UDP broadcast for the ring server port.
16
17
 
17
18
  The *providers* make remote Watir objects available to the tuple space hosted by the *controller*. Typically you will host one or many providers on your grid network, for example, each PC may become a single provider of a Watir tuple in the form of an Internet Explorer, Firefox, Safari or WebDriver browser object.
18
19
 
20
+ ==== WatirGrid IS
21
+ - A lightweight, pure Ruby implementation of distributed computing using DRb and Rinda.
22
+ - A simple way to control remote Watir objects in parallel.
23
+ - Cross platform friendly and works on Windows, OSX or Linux.
24
+ - Open source, you're already looking in the right place if you want the source code.
25
+ - WebDriver friendly, thanks to the wire protocol, WatirGrid happily runs with WebDriver implementations such as watir-webdriver and selenium-webdriver.
26
+
27
+ ==== WatirGrid IS NOT
28
+ - A "grid management" system. If you're looking to control individual resources, such as starting and stopping workstations or VMs you should look at the commercial implementation at Gridinit.com[http://gridinit.com]
29
+
30
+ - Selenium Grid. If you're looking for a full blown implementation of distributed computing you should take a look at Selenium Grid[http://selenium-grid.seleniumhq.org/]
31
+
32
+
19
33
  === Simple Example
20
34
 
21
- Pick a server to host the 'controller' for the ring server and execute the following:
35
+ Pick a server to host the *controller* for the ring server and execute the following:
22
36
  $ controller
23
37
 
24
- This should find your external facing IP and start the corresponding DRb and Ring Servers:
38
+ This should find your external facing IP and start the *controller*:
25
39
  I, [2011-04-09 18:06:19 #1971] INFO -- : Controller started on : druby://127.0.0.1:11235
26
40
 
27
- On each client PC, host the 'provider' for the distributed (DRb) Watir objects
28
- $ provider -b ie -c druby://127.0.0.1:11235
41
+ On each remote machine, host the *provider* for the distributed (DRb) Watir object:
42
+ $ provider -d watir -c druby://127.0.0.1:11235
29
43
 
30
- This should find the recently started Ring Server and register a tuple for the Watir object:
44
+ This should find the recently started *controller* and register the *provider*:
31
45
  I, [2011-04-09 18:06:26 #1972] INFO -- : Provider started on : druby://127.0.0.1:11236
32
46
  I, [2011-04-09 18:06:26 #1972] INFO -- : Controller found on : druby://127.0.0.1:11235
33
47
  I, [2011-04-09 18:06:26 #1972] INFO -- : Provider registered : druby://127.0.0.1:11235
@@ -47,26 +61,46 @@ e.g.
47
61
  You may wish to host the controller and providers on different machines in a real scenario. You can specify things like server hostnames, ports and access control lists for each of the different types of servers. For more help see:
48
62
  $ controller --help
49
63
  Usage: controller [options]
50
- Specific options:
51
- -H, --drb-server-host [HOST] Specify DRb Server interface to host on
52
- -d, --drb-server-port [PORT] Specify DRb Server port to listen on
53
- -h, --ring-server-host [HOST] Specify Ring Server interface to host on
54
- -r, --ring-server-port [PORT] Specify Ring Server port to listen on
55
- -a, --access-control-list [ACLS] Specify a comma separated Access Control List
56
- -l, --log-level [LEVEL] Specify log level {DEBUG|INFO|ERROR}
64
+
65
+ Advanced Options:
66
+ -h, --drb HOST Specify the DRb host for this controller to bind to.
67
+ -p, --drb-port PORT Specify the DRb port for this controller to listen on.
68
+ -H, --ring-server HOST Specify the ring server host for this controller to bind to.
69
+ -P, --ring-server-port PORT Specify the ring server port for this controller to listen on.
70
+ -a, --access-control-list ACL Specify a comma separated Access Control List
71
+ -l, --log LEVEL Specify the logging level:
72
+ - DEBUG
73
+ - INFO
74
+ - ERROR
57
75
  --help Show this message
58
76
 
59
77
  $ provider --help
60
- Usage: Usage: provider -b BROWSER_TYPE [options]
61
- Specific options:
62
- -b, --browser-type TYPE Specify browser type to register {ie|firefox|safari|webdriver}
63
- -c, --controller-uri [URI] Specify Controller URI e.g. druby://127.0.0.1:11235
64
- -H, --drb-server-host [HOST] Specify DRb Server interface to host on
65
- -d, --drb-server-port [PORT] Specify DRb Server port to listen on
66
- -h, --ring-server-host [HOST] Specify Ring Server host to connect to
67
- -r, --ring-server-port [PORT] Specify Ring Server port to broadcast on
68
- -a, --access-control-list [ACL] Specify a comma separated Access Control List
69
- -l, --log-level [LEVEL] Specify log level {DEBUG|INFO|ERROR}
78
+ Usage: provider -d DRIVER [options]
79
+
80
+ Basic Options:
81
+ -d, --driver TYPE Specify driver type to use on this provider:
82
+ - watir
83
+ - webdriver
84
+ - selenium
85
+ - firewatir
86
+ - safariwatir
87
+ -c, --controller URI Specify the controller URI to register this provider on e.g.:
88
+ - druby://127.0.0.1:11235
89
+ -b, --browser TYPE Specify the browser type to start when using webdriver or selenium:
90
+ - firefox
91
+ - chrome
92
+ - ie
93
+
94
+ Advanced Options:
95
+ -h, --drb HOST Specify the DRb host for this provider to bind to.
96
+ -p, --drb-port PORT Specify the DRb port for this provider to listen on.
97
+ -H, --ring-server HOST Optionally specify the ring server host if not using controller URI.
98
+ -P, --ring-server-port PORT Optionally specify the ring server port if not using controller URI.
99
+ -a, --access-control-list ACL Specify a comma separated Access Control List
100
+ -l, --log LEVEL Specify the logging level:
101
+ - DEBUG
102
+ - INFO
103
+ - ERROR
70
104
  --help Show this message
71
105
 
72
106
  == Copyright
data/Rakefile CHANGED
@@ -9,27 +9,13 @@ begin
9
9
  gem.email = "tim.koops@gmail.com"
10
10
  gem.homepage = "http://github.com/90kts/watirgrid"
11
11
  gem.authors = ["Tim Koopmans"]
12
- gem.version = "1.1.3.pre"
12
+ gem.version = "1.1.3"
13
13
  end
14
14
  rescue LoadError
15
15
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
16
  end
17
17
 
18
18
  require 'spec/rake/spectask'
19
- desc "Run unit tests for Watir, FireWatir and SafariWatir"
20
- Spec::Rake::SpecTask.new('unit_tests_watir') do |t|
21
- t.spec_files = FileList['spec/**/grid_spec.rb']
22
- t.spec_opts = ["--format", "nested", "-c"]
23
- t.fail_on_error = false
24
- end
25
-
26
- desc "Run unit tests for WebDriver"
27
- Spec::Rake::SpecTask.new('unit_tests_webdriver') do |t|
28
- t.spec_files = FileList['spec/**/webdriver_spec.rb']
29
- t.spec_opts = ["--format", "nested", "-c"]
30
- t.fail_on_error = false
31
- end
32
-
33
19
  require 'rake/rdoctask'
34
20
  Rake::RDocTask.new do |rdoc|
35
21
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
data/bin/controller CHANGED
@@ -8,39 +8,42 @@ options = {}
8
8
  OptionParser.new do |opts|
9
9
  opts.banner = "Usage: controller [options]"
10
10
  opts.separator ""
11
- opts.separator "Specific options:"
12
- opts.on("-H", "--drb-server-host [HOST]", String,
13
- "Specify DRb Server interface to host on") do |h|
11
+ opts.separator "Advanced Options:"
12
+ opts.on("-h", "--drb HOST",
13
+ "Specify the DRb host for this controller to bind to.") do |h|
14
14
  options[:drb_server_host] = h || nil
15
15
  end
16
- opts.on("-d", "--drb-server-port [PORT]", Integer,
17
- "Specify DRb Server port to listen on") do |d|
18
- options[:drb_server_port] = d
16
+ opts.on("-p", "--drb-port PORT",
17
+ "Specify the DRb port for this controller to listen on.") do |p|
18
+ options[:drb_server_port] = p
19
19
  end
20
- opts.on("-h", "--ring-server-host [HOST]", String,
21
- "Specify Ring Server interface to host on") do |h|
20
+ opts.on("-H", "--ring-server HOST",
21
+ "Specify the ring server host for this controller to bind to.") do |h|
22
22
  options[:ring_server_host] = h || nil
23
23
  end
24
- opts.on("-r", "--ring-server-port [PORT]", Integer,
25
- "Specify Ring Server port to listen on") do |r|
26
- options[:ring_server_port] = r
24
+ opts.on("-P", "--ring-server-port PORT",
25
+ "Specify the ring server port for this controller to listen on.") do |p|
26
+ options[:ring_server_port] = p
27
27
  end
28
- opts.on("-a", "--access-control-list [ACLS]", Array,
29
- "Specify a comma separated Access Control List") do |a|
28
+ opts.on("-a", "--access-control-list ACL", Array,
29
+ "Specify a comma separated Access Control List.") do |a|
30
30
  options[:acls] = a
31
31
  end
32
- opts.on("-l", "--log-level [LEVEL]", String,
33
- "Specify log level {DEBUG|INFO|ERROR}") do |l|
34
- case l
35
- when 'DEBUG'
36
- options[:loglevel] = Logger::DEBUG
37
- when 'INFO'
38
- options[:loglevel] = Logger::INFO
39
- when 'ERROR'
40
- options[:loglevel] = Logger::ERROR
41
- else
42
- options[:loglevel] = Logger::ERROR
43
- end
32
+ opts.on("-l", "--log LEVEL",
33
+ "Specify the logging level:",
34
+ " - DEBUG",
35
+ " - INFO",
36
+ " - ERROR") do |l|
37
+ case l
38
+ when 'DEBUG'
39
+ options[:loglevel] = Logger::DEBUG
40
+ when 'INFO'
41
+ options[:loglevel] = Logger::INFO
42
+ when 'ERROR'
43
+ options[:loglevel] = Logger::ERROR
44
+ else
45
+ options[:loglevel] = Logger::ERROR
46
+ end
44
47
  end
45
48
  opts.on_tail("-h", "--help", "Show this message") do
46
49
  puts opts
data/bin/provider CHANGED
@@ -6,39 +6,57 @@ require 'optparse'
6
6
 
7
7
  options = {}
8
8
  optparse = OptionParser.new do |opts|
9
- opts.banner = "Usage: provider -b BROWSER_TYPE [options]"
9
+ opts.banner = "Usage: provider -d DRIVER [options]"
10
10
  opts.separator ""
11
- opts.separator "Specific options:"
12
- opts.on("-b", "--browser-type TYPE",
13
- "Specify driver for browser type to register {watir|firewatir|safariwatir|webdriver|zombie}") do |b|
14
- options[:browser_type] = b
11
+ opts.separator "Basic Options:"
12
+ opts.on("-d", "--driver TYPE",
13
+ "Specify driver type to use on this provider:",
14
+ " - watir",
15
+ " - webdriver",
16
+ " - selenium",
17
+ " - firewatir",
18
+ " - safariwatir") do |d|
19
+ options[:driver] = d
15
20
  end
16
- opts.on("-c", "--controller-uri [URI]",
17
- "Specify Controller URI e.g. druby://127.0.0.1:11235") do |h|
18
- options[:controller_uri] = h || nil
21
+ opts.on("-c", "--controller URI",
22
+ "Specify the controller URI to register this provider on e.g.:",
23
+ " - druby://127.0.0.1:11235") do |c|
24
+ options[:controller_uri] = c || nil
19
25
  end
20
- opts.on("-H", "--drb-server-host [HOST]",
21
- "Specify DRb Server interface to host on") do |h|
26
+ opts.on("-b", "--browser TYPE",
27
+ "Specify the browser type to start when using webdriver or selenium:",
28
+ " - firefox",
29
+ " - chrome",
30
+ " - ie") do |b|
31
+ options[:browser_type] = b || nil
32
+ end
33
+ opts.separator ""
34
+ opts.separator "Advanced Options:"
35
+ opts.on("-h", "--drb HOST",
36
+ "Specify the DRb host for this provider to bind to.") do |h|
22
37
  options[:drb_server_host] = h || nil
23
38
  end
24
- opts.on("-d", "--drb-server-port [PORT]",
25
- "Specify DRb Server port to listen on") do |d|
26
- options[:drb_server_port] = d
39
+ opts.on("-p", "--drb-port PORT",
40
+ "Specify the DRb port for this provider to listen on.") do |p|
41
+ options[:drb_server_port] = p
27
42
  end
28
- opts.on("-h", "--ring-server-host [HOST]",
29
- "Specify Ring Server host to connect to") do |h|
43
+ opts.on("-H", "--ring-server HOST",
44
+ "Optionally specify the ring server host if not using controller URI.") do |h|
30
45
  options[:ring_server_host] = h || nil
31
46
  end
32
- opts.on("-r", "--ring-server-port [PORT]",
33
- "Specify Ring Server port to broadcast on") do |r|
34
- options[:ring_server_port] = r
47
+ opts.on("-P", "--ring-server-port PORT",
48
+ "Optionally specify the ring server port if not using controller URI.") do |p|
49
+ options[:ring_server_port] = p
35
50
  end
36
- opts.on("-a", "--access-control-list [ACL]", Array,
37
- "Specify a comma separated Access Control List") do |a|
51
+ opts.on("-a", "--access-control-list ACL", Array,
52
+ "Specify a comma separated Access Control List.") do |a|
38
53
  options[:acls] = a
39
54
  end
40
- opts.on("-l", "--log-level [LEVEL]",
41
- "Specify log level {DEBUG|INFO|ERROR}") do |l|
55
+ opts.on("-l", "--log LEVEL",
56
+ "Specify the logging level:",
57
+ " - DEBUG",
58
+ " - INFO",
59
+ " - ERROR") do |l|
42
60
  case l
43
61
  when 'DEBUG'
44
62
  options[:loglevel] = Logger::DEBUG
@@ -58,7 +76,7 @@ end
58
76
 
59
77
  begin
60
78
  optparse.parse!
61
- mandatory = [:browser_type]
79
+ mandatory = [:driver]
62
80
  missing = mandatory.select{ |param| options[param].nil? }
63
81
  if not missing.empty?
64
82
  puts "Missing options: #{missing.join(', ')}"
@@ -76,7 +94,7 @@ provider = Provider.new(
76
94
  :drb_server_port => options[:drb_server_port] || 11236,
77
95
  :ring_server_host => options[:ring_server_host],
78
96
  :ring_server_port => options[:ring_server_port] || 12358,
79
- :browser_type => options[:browser_type] || nil,
97
+ :driver => options[:driver] || nil,
80
98
  :controller_uri => options[:controller_uri] || nil,
81
99
  :acls => options[:acls] || %w{ allow all },
82
100
  :loglevel => options[:loglevel])
data/lib/provider.rb CHANGED
@@ -11,23 +11,22 @@ module Watir
11
11
 
12
12
  ##
13
13
  # Extend Watir with a Provider class
14
- # to determine which browser type is supported by the
14
+ # to determine which driver type is supported by the
15
15
  # remote DRb process. This returns the DRb front object.
16
16
  class Provider
17
17
 
18
18
  include DRbUndumped # all objects will be proxied, not copied
19
19
  attr_reader :browser
20
20
 
21
- def initialize(browser = nil)
22
- browser = (browser || 'tmp').downcase.to_sym
23
- case browser
24
- when :safari, :safariwatir
21
+ def initialize(driver=nil)
22
+ case driver.downcase.to_sym
23
+ when :safariwatir
25
24
  require 'safariwatir'
26
25
  @browser = Watir::Safari
27
- when :firefox, :firewatir
26
+ when :firewatir
28
27
  require 'firewatir'
29
28
  @browser = FireWatir::Firefox
30
- when :ie, :watir
29
+ when :watir
31
30
  require 'watir'
32
31
  @browser = Watir::IE
33
32
  when :webdriver
@@ -41,30 +40,27 @@ module Watir
41
40
  require 'watir-webdriver'
42
41
  require 'selenium-webdriver'
43
42
  @browser = Watir::Browser
44
- when :zombie
45
- require 'watir-zombie'
46
- @browser = Watir::Zombie
47
43
  when :selenium
48
44
  require 'selenium-webdriver'
49
45
  @browser = Selenium::WebDriver
50
46
  end
51
47
  end
52
48
 
53
- def new_browser(webdriver_browser_type = :firefox)
49
+ def new_browser(browser_type='firefox')
54
50
  case @browser.inspect
55
51
  when "Selenium::WebDriver"
56
- if webdriver_browser_type == :htmlunit
52
+ if browser_type == :htmlunit
57
53
  caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
58
54
  @browser.for(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)
59
55
  else
60
- @browser.for webdriver_browser_type
56
+ @browser.for browser_type.to_sym
61
57
  end
62
58
  when "Watir::Browser"
63
- if webdriver_browser_type == :htmlunit
59
+ if @browser_type == :htmlunit
64
60
  caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
65
61
  @browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)
66
62
  else
67
- @browser.new webdriver_browser_type
63
+ @browser.new browser_type.to_sym
68
64
  end
69
65
  when "Watir::Safari"
70
66
  @browser.new
@@ -77,85 +73,6 @@ module Watir
77
73
  end
78
74
  end
79
75
 
80
- ##
81
- # Get a list of running browsers (optionally specified by browser)
82
- # 'iexplore','firefox','firefox-bin','chrome','safari','opera'
83
- def get_running_browsers(browser=nil)
84
- browsers = browser || \
85
- ['iexplore','firefox','firefox-bin','chrome','safari','opera']
86
- case Config::CONFIG['arch']
87
- when /mswin/
88
- %x[tasklist].split(/\s+/).collect { |x| x[/\w+/]} \
89
- & browsers.collect { |x| x.downcase }
90
- when /linux|darwin/
91
- %x[ps -A | grep -v ruby].split(/\/|\s+/).collect { |x| x.downcase} \
92
- & browsers
93
- end
94
- end
95
-
96
- def get_running_processes
97
- %x[ps -A | grep -v ruby].split(/\/|\s+/).collect.uniq
98
- end
99
-
100
- ##
101
- # Kill any browser running
102
- def kill_all_browsers
103
- case Config::CONFIG['arch']
104
- when /mswin/
105
- browsers = ['iexplore.exe', 'firefox.exe', 'chrome.exe']
106
- browsers.each { |browser| %x[taskkill /F /IM #{browser}] }
107
- when /linux/
108
- browsers = ['firefox', 'chrome', 'opera']
109
- browsers.each { |browser| %x[killall -r #{browser}] }
110
- when /darwin/
111
- browsers = ['firefox-bin', 'Chrome', 'Safari']
112
- browsers.each { |browser| %x[pkill -9 #{browser}] }
113
- end
114
- end
115
-
116
- ##
117
- # Kill all browsers specified by browser name
118
- # Windows: 'iexplore.exe', 'firefox.exe', 'chrome.exe'
119
- # Linux: 'firefox', 'chrome', 'opera'
120
- # OSX: 'firefox-bin', 'Chrome', 'Safari'
121
- def kill_browser(browser)
122
- case Config::CONFIG['arch']
123
- when /mswin/
124
- %x[taskkill /F /IM #{browser}]
125
- when /linux/
126
- %x[killall -r #{browser}]
127
- when /darwin/
128
- %x[killall -m #{browser}]
129
- end
130
- end
131
-
132
- ##
133
- # Start firefox (with an optional bin path) using the -jssh extension
134
- def start_firefox_jssh(path=nil)
135
- case Config::CONFIG['arch']
136
- when /mswin/
137
- bin = path || "C:/Program Files/Mozilla Firefox/firefox.exe"
138
- when /linux/
139
- bin = path || "/usr/bin/firefox"
140
- when /darwin/
141
- bin = path || "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
142
- end
143
- # fork off and die!
144
- Thread.new {system(bin, "about:blank", "-jssh")}
145
- end
146
-
147
- ##
148
- # Get the logged-in user
149
- def get_logged_in_user
150
- %x[whoami].chomp
151
- end
152
-
153
- ##
154
- # Grep for a process (Linux/OSX-with-port only)
155
- def process_grep(pattern)
156
- %x[pgrep -l #{pattern}].split(/\n/)
157
- end
158
-
159
76
  def renew_provider
160
77
  self.class.superclass
161
78
  end
@@ -174,22 +91,21 @@ class Provider
174
91
  @ring_server_host = params[:ring_server_host] || external_interface
175
92
  @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT
176
93
  @controller_uri = params[:controller_uri]
177
-
178
- @renewer = params[:renewer] || Rinda::SimpleRenewer.new
179
- @browser_type = params[:browser_type] || nil
94
+ @renewer = params[:renewer] || Rinda::SimpleRenewer.new
95
+ @driver = params[:driver] || 'webdriver'
96
+ @browser_type = params[:browser_type] || 'firefox'
180
97
 
181
98
  logfile = params[:logfile] || STDOUT
182
99
  @log = Logger.new(logfile, 'daily')
183
100
  @log.level = params[:loglevel] || Logger::INFO
184
101
  @log.datetime_format = "%Y-%m-%d %H:%M:%S "
185
-
186
102
  end
187
103
 
188
104
  ##
189
- # Start providing watir objects on the ring server
190
- def start
105
+ # Start providing Watir objects on the ring server
106
+ def start(params = {})
191
107
  # create a DRb 'front' object
192
- watir_provider = Watir::Provider.new(@browser_type)
108
+ watir_provider = Watir::Provider.new(@driver)
193
109
  @log.debug("Watir provider is : #{watir_provider}")
194
110
  architecture = Config::CONFIG['arch']
195
111
  hostname = ENV['SERVER_NAME'] || %x{hostname}.strip
@@ -213,8 +129,8 @@ class Provider
213
129
  'A watir provider',
214
130
  hostname,
215
131
  architecture,
216
- @browser_type
217
- ]
132
+ @driver
133
+ ]
218
134
 
219
135
  # locate the Rinda Ring Server via a UDP broadcast
220
136
  @log.debug("Broadcast Ring Server : druby://#{@ring_server_host}:#{@ring_server_port}")
data/lib/watirgrid.rb CHANGED
@@ -13,20 +13,20 @@ module Watir
13
13
  attr_accessor :drb_server_uri, :ring_server, :browsers, :tuples, :providers
14
14
 
15
15
  def initialize(params = {})
16
- @drb_server_host = params[:drb_server_host] || external_interface
17
- @drb_server_port = params[:drb_server_port] || 0
18
- @controller_uri = params[:controller_uri]
19
- @ring_server_host = params[:ring_server_host] || external_interface unless @controller_uri
20
- @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT
21
- @renewer = params[:renewer] || Rinda::SimpleRenewer.new
22
- logfile = params[:logfile] || STDOUT
23
- @log = Logger.new(logfile, 'daily')
24
- @log.level = params[:loglevel] || Logger::ERROR
25
- @log.datetime_format = "%Y-%m-%d %H:%M:%S "
26
- @webdriver_browser_type = params[:browser].to_sym if params[:browser]
27
- @browsers = []
28
- @tuples = []
29
- @providers = []
16
+ @drb_server_host = params[:drb_server_host] || external_interface
17
+ @drb_server_port = params[:drb_server_port] || 0
18
+ @controller_uri = params[:controller_uri]
19
+ @ring_server_host = params[:ring_server_host] || external_interface unless @controller_uri
20
+ @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT
21
+ @renewer = params[:renewer] || Rinda::SimpleRenewer.new
22
+ logfile = params[:logfile] || STDOUT
23
+ @log = Logger.new(logfile, 'daily')
24
+ @log.level = params[:loglevel] || Logger::ERROR
25
+ @log.datetime_format = "%Y-%m-%d %H:%M:%S "
26
+ @browser_type = params[:browser_type]
27
+ @browsers = []
28
+ @tuples = []
29
+ @providers = []
30
30
  end
31
31
 
32
32
  ##
@@ -55,7 +55,7 @@ module Watir
55
55
  def setup
56
56
  @browsers.each_with_index do |browser, index|
57
57
  sleep 0.15
58
- @providers[index] ||= browser[:object].new_browser(@webdriver_browser_type)
58
+ @providers[index] ||= browser[:object].new_browser @browser_type
59
59
  end
60
60
  end
61
61
 
@@ -83,7 +83,7 @@ module Watir
83
83
  sleep rampup(grid.size, params)
84
84
  threads << Thread.new do
85
85
  start = ::Time.now
86
- @browser = browser[:object].new_browser
86
+ @browser = browser[:object].new_browser params[:browser_type]
87
87
  yield @browser, "#{index}"
88
88
  end
89
89
  end
@@ -176,7 +176,7 @@ module Watir
176
176
  nil, # provider description
177
177
  nil, # hostname
178
178
  params[:architecture],
179
- params[:browser_type]
179
+ params[:driver]
180
180
  ])
181
181
  end
182
182
 
@@ -212,7 +212,7 @@ module Watir
212
212
  tuple_hash[:description] = tuple[3]
213
213
  tuple_hash[:hostname] = tuple[4]
214
214
  tuple_hash[:architecture] = tuple[5]
215
- tuple_hash[:browser_type] = tuple[6]
215
+ tuple_hash[:driver] = tuple[6]
216
216
  tuple_hash
217
217
  end
218
218
 
@@ -8,7 +8,7 @@ describe 'Using the Grid Control method' do
8
8
  @controller.start
9
9
  provider = Provider.new(
10
10
  :ring_server_port => 12357,
11
- :loglevel => Logger::ERROR, :browser_type => 'safari')
11
+ :loglevel => Logger::ERROR, :driver => 'safariwatir')
12
12
  provider.start
13
13
  end
14
14
 
@@ -44,7 +44,8 @@ describe 'Starting and Stopping Providers on the Grid' do
44
44
  :drb_server_host => '127.0.0.1',
45
45
  :ring_server_host => '127.0.0.1',
46
46
  :ring_server_port => 12350,
47
- :loglevel => Logger::ERROR)
47
+ :loglevel => Logger::ERROR,
48
+ :driver => 'safariwatir')
48
49
  provider.start
49
50
  end
50
51
 
@@ -62,7 +63,7 @@ describe 'Using the Grid' do
62
63
  1.upto(5) do
63
64
  provider = Provider.new(
64
65
  :ring_server_port => 12357,
65
- :loglevel => Logger::ERROR, :browser_type => 'safari')
66
+ :loglevel => Logger::ERROR, :driver => 'safariwatir')
66
67
  provider.start
67
68
  end
68
69
  end
@@ -101,32 +102,32 @@ describe 'Using the Grid' do
101
102
  grid.size.should == 0
102
103
  end
103
104
 
104
- it 'should register 4 new providers on the grid' do
105
- 1.upto(4) do
105
+ it 'should register 3 new providers on the grid' do
106
+ 1.upto(3) do
106
107
  provider = Provider.new(:ring_server_port => 12357,
107
- :loglevel => Logger::ERROR, :browser_type => 'safari')
108
+ :loglevel => Logger::ERROR, :driver => 'safariwatir')
108
109
  provider.start
109
110
  end
110
111
  end
111
112
 
112
- it 'should take any 1 provider based on :browser_type from the grid' do
113
+ it 'should take any 1 provider based on :driver from the grid' do
113
114
  grid = Watir::Grid.new(:ring_server_port => 12357)
114
115
  grid.start(:quantity => 1,
115
- :take_all => true, :browser_type => 'safari')
116
+ :take_all => true, :driver => 'safariwatir')
116
117
  grid.size.should == 1
117
118
  end
118
119
 
119
- it 'should fail to find any providers on the grid based on a specific :browser_type' do
120
+ it 'should fail to find any providers on the grid based on a specific :driver' do
120
121
  grid = Watir::Grid.new(:ring_server_port => 12357)
121
122
  grid.start(:quantity => 1,
122
- :take_all => true, :browser_type => 'firefox')
123
+ :take_all => true, :driver => 'watir')
123
124
  grid.size.should == 0
124
125
  end
125
126
 
126
- it 'should fail to find any providers on the grid based on an unknown :browser_type' do
127
+ it 'should fail to find any providers on the grid based on an unknown :driver' do
127
128
  grid = Watir::Grid.new(:ring_server_port => 12357)
128
129
  grid.start(:quantity => 1,
129
- :take_all => true, :browser_type => 'penguin')
130
+ :take_all => true, :driver => 'operawatir')
130
131
  grid.size.should == 0
131
132
  end
132
133
 
@@ -162,26 +163,6 @@ describe 'Using the Grid' do
162
163
  grid.size.should == 0
163
164
  end
164
165
 
165
- it 'should take the last provider on the grid and execute some Watir code in Safari' do
166
- grid = Watir::Grid.new(:ring_server_port => 12357)
167
- grid.start(:quantity => 1, :take_all => true)
168
- threads = []
169
- grid.browsers.each do |browser|
170
- threads << Thread.new do
171
- browser[:hostname].should == `hostname`.strip
172
- browser[:architecture].should == Config::CONFIG['arch']
173
- browser[:browser_type].should == 'safari'
174
- b = browser[:object].new_browser
175
- b.goto("http://www.google.com")
176
- b.text_field(:name, 'q').set("watirgrid")
177
- #b.button(:name, "btnI").click
178
- b.close
179
- end
180
- end
181
- threads.each {|thread| thread.join}
182
- grid.size.should == 1
183
- end
184
-
185
166
  it 'should find no more providers on the grid' do
186
167
  grid = Watir::Grid.new(:ring_server_port => 12357)
187
168
  grid.start(:read_all => true)
@@ -8,7 +8,7 @@ describe 'Using the Grid with WebDriver' do
8
8
  1.upto(1) do
9
9
  provider = Provider.new(
10
10
  :ring_server_port => 12356,
11
- :loglevel => Logger::ERROR, :browser_type => 'selenium')
11
+ :loglevel => Logger::ERROR, :driver => 'selenium')
12
12
  provider.start
13
13
  end
14
14
  end
@@ -17,31 +17,13 @@ describe 'Using the Grid with WebDriver' do
17
17
  @controller.stop
18
18
  end
19
19
 
20
- it 'should take the last provider on the grid and execute some Watir code in Selenium::WebDriver with Firefox' do
21
- grid = Watir::Grid.new(:ring_server_port => 12356)
22
- grid.start(:quantity => 1, :take_all => true)
23
- threads = []
24
- grid.browsers.each do |browser|
25
- threads << Thread.new do
26
- browser[:hostname].should == `hostname`.strip
27
- browser[:architecture].should == Config::CONFIG['arch']
28
- browser[:browser_type].should == 'selenium'
29
- driver = browser[:object].new_browser(:firefox)
30
- driver.navigate.to "http://google.com"
31
- element = driver.find_element(:name, 'q')
32
- element.send_keys "Hello WebDriver!"
33
- element.submit
34
- driver.quit
35
- end
20
+ it 'should control a grid in Selenium::WebDriver with Firefox' do
21
+ Watir::Grid.control(:ring_server_port => 12356, :browser_type => 'firefox') do |driver, index|
22
+ driver.navigate.to "http://google.com"
23
+ element = driver.find_element(:name, 'q')
24
+ element.send_keys "Hello WebDriver!"
25
+ element.submit
26
+ driver.quit
36
27
  end
37
- threads.each {|thread| thread.join}
38
- grid.size.should == 1
39
- end
40
-
41
- it 'should find no more providers on the grid' do
42
- grid = Watir::Grid.new(:ring_server_port => 12356)
43
- grid.start(:read_all => true)
44
- grid.size.should == 0
45
28
  end
46
29
  end
47
-
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'watirgrid'
4
+ require 'ap'
@@ -17,29 +17,21 @@ describe 'Using the Grid with WebDriver' do
17
17
  @controller.stop
18
18
  end
19
19
 
20
- it 'should take the last provider on the grid and execute some Watir code in WebDriver with Firefox' do
21
- grid = Watir::Grid.new(:ring_server_port => 12356)
22
- grid.start(:quantity => 1, :take_all => true)
23
- threads = []
24
- grid.browsers.each do |browser|
25
- threads << Thread.new do
26
- browser[:hostname].should == `hostname`.strip
27
- browser[:architecture].should == Config::CONFIG['arch']
28
- browser[:browser_type].should == 'webdriver'
29
- b = browser[:object].new_browser(:firefox)
30
- b.goto("http://www.google.com")
31
- b.text_field(:name, 'q').set("watirgrid")
32
- b.button(:name, "btnI").click
33
- b.close
34
- end
20
+ it 'should control a grid in WebDriver with Firefox' do
21
+ Watir::Grid.control(:ring_server_port => 12356, :browser_type => 'firefox') do |browser, index|
22
+ p "I am browser index #{index}"
23
+ browser.goto "http://google.com"
24
+ p browser.title
25
+ browser.close
35
26
  end
36
- threads.each {|thread| thread.join}
37
- grid.size.should == 1
38
27
  end
39
28
 
40
- it 'should find no more providers on the grid' do
41
- grid = Watir::Grid.new(:ring_server_port => 12356)
42
- grid.start(:read_all => true)
43
- grid.size.should == 0
29
+ it 'should iterate over a grid in WebDriver with Chrome' do
30
+ grid = Watir::Grid.new(:ring_server_port => 12356, :browser_type => 'chrome')
31
+ grid.start(:initiate => true)
32
+ grid.iterate do |browser|
33
+ browser.goto "http://google.com"
34
+ browser.close
35
+ end
44
36
  end
45
37
  end
data/watirgrid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{watirgrid}
8
- s.version = "1.1.2"
8
+ s.version = "1.1.3.pre"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Koopmans"]
12
- s.date = %q{2011-05-06}
12
+ s.date = %q{2011-05-16}
13
13
  s.description = %q{WatirGrid allows for distributed testing across a grid network using Watir.}
14
14
  s.email = %q{tim.koops@gmail.com}
15
15
  s.executables = ["listener", "controller", "provider"]
@@ -31,6 +31,10 @@ Gem::Specification.new do |s|
31
31
  "examples/basic/example_webdriver_remote.rb",
32
32
  "examples/cucumber/example.feature",
33
33
  "examples/cucumber/step_definitions/example_steps.rb",
34
+ "examples/cucumber/support/env.rb",
35
+ "examples/parallel/cucumber/example.feature",
36
+ "examples/parallel/cucumber/step_definitions/example_steps.rb",
37
+ "examples/parallel/cucumber/support/env.rb",
34
38
  "lib/controller.rb",
35
39
  "lib/listener.rb",
36
40
  "lib/provider.rb",
@@ -55,6 +59,9 @@ Gem::Specification.new do |s|
55
59
  "examples/basic/example_webdriver.rb",
56
60
  "examples/basic/example_webdriver_remote.rb",
57
61
  "examples/cucumber/step_definitions/example_steps.rb",
62
+ "examples/cucumber/support/env.rb",
63
+ "examples/parallel/cucumber/step_definitions/example_steps.rb",
64
+ "examples/parallel/cucumber/support/env.rb",
58
65
  "spec/control_spec.rb",
59
66
  "spec/grid_spec.rb",
60
67
  "spec/memory_spec.rb",
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirgrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961915984
5
- prerelease: 6
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
9
  - 3
10
- - pre
11
- version: 1.1.3.pre
10
+ version: 1.1.3
12
11
  platform: ruby
13
12
  authors:
14
13
  - Tim Koopmans
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-05-16 00:00:00 +10:00
18
+ date: 2011-05-26 00:00:00 +10:00
20
19
  default_executable:
21
20
  dependencies: []
22
21
 
@@ -33,7 +32,6 @@ extra_rdoc_files:
33
32
  - README.rdoc
34
33
  files:
35
34
  - .document
36
- - EXAMPLES.rdoc
37
35
  - LICENSE
38
36
  - README.rdoc
39
37
  - Rakefile
@@ -54,13 +52,11 @@ files:
54
52
  - lib/provider.rb
55
53
  - lib/watirgrid.rb
56
54
  - rdoc/logo.png
57
- - spec/control_spec.rb
58
- - spec/grid_spec.rb
55
+ - spec/grid_control_spec.rb
56
+ - spec/grid_management_spec.rb
59
57
  - spec/memory_spec.rb
60
58
  - spec/selenium_webdriver_spec.rb
61
59
  - spec/spec_helper.rb
62
- - spec/utilities_spec.rb
63
- - spec/webdriver_remote_spec.rb
64
60
  - spec/webdriver_spec.rb
65
61
  - watirgrid.gemspec
66
62
  has_rdoc: true
@@ -84,14 +80,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
80
  required_rubygems_version: !ruby/object:Gem::Requirement
85
81
  none: false
86
82
  requirements:
87
- - - ">"
83
+ - - ">="
88
84
  - !ruby/object:Gem::Version
89
- hash: 25
85
+ hash: 3
90
86
  segments:
91
- - 1
92
- - 3
93
- - 1
94
- version: 1.3.1
87
+ - 0
88
+ version: "0"
95
89
  requirements: []
96
90
 
97
91
  rubyforge_project:
@@ -107,11 +101,9 @@ test_files:
107
101
  - examples/cucumber/support/env.rb
108
102
  - examples/parallel/cucumber/step_definitions/example_steps.rb
109
103
  - examples/parallel/cucumber/support/env.rb
110
- - spec/control_spec.rb
111
- - spec/grid_spec.rb
104
+ - spec/grid_control_spec.rb
105
+ - spec/grid_management_spec.rb
112
106
  - spec/memory_spec.rb
113
107
  - spec/selenium_webdriver_spec.rb
114
108
  - spec/spec_helper.rb
115
- - spec/utilities_spec.rb
116
- - spec/webdriver_remote_spec.rb
117
109
  - spec/webdriver_spec.rb
data/EXAMPLES.rdoc DELETED
@@ -1,132 +0,0 @@
1
- = Common Examples
2
-
3
- == Starting a Controller
4
- A controller has the following startup options:
5
- controller --help
6
- Usage: controller [options]
7
- Specific options:
8
- -H, --drb-server-host HOST Specify DRb Server interface to host on
9
- -d, --drb-server-port PORT Specify DRb Server port to listen on
10
- -h, --ring-server-host HOST Specify Ring Server interface to host on
11
- -r, --ring-server-port PORT Specify Ring Server port to listen on
12
- -a, --access-control-list ACLS Specify a comma separated Access Control List
13
- -l, --log-level LEVEL Specify log level {DEBUG|INFO|ERROR}
14
- --help Show this message
15
-
16
- === Default
17
- To start a controller with default settings:
18
- $ controller
19
-
20
- This will bind the controller to your external facing interface and register the ring server to listen on port 12358
21
- e.g.
22
- DRb server started on : druby://143.238.105.61:11235
23
- Ring server started on: druby://143.238.105.61:12358
24
-
25
- === Start on specific interface or ports
26
- To start a controller on specific interfaces or ports:
27
- $ controller -H 127.0.0.1 -h 127.0.0.1 -d 12345 -r 54321
28
-
29
- This will bind the controller to the localhost (127.0.0.1) with the DRb server listening on port 12345 and the ring server listening on port 54321
30
- e.g.
31
- DRb server started on : druby://127.0.0.1:12345
32
- Ring server started on: druby://127.0.0.1:54321
33
-
34
-
35
- === Start with access control list
36
- To start a controller with an access control list:
37
- $ controller -a deny,all,allow,127.0.0.1 -H 127.0.0.1 -h 127.0.0.1
38
-
39
- This will bind the controller to the localhost (127.0.0.1) and deny all access to the controller by default, whilst allowing access from localhost only. The ACL constructor takes an array of strings. The first string of a pair is always “allow” or “deny”, and it’s followed by the address or addresses to allow or deny access.
40
-
41
- == Starting a Provider
42
- A provider has similar startup options:
43
- provider --help
44
- # Usage: provider [options]
45
- # Specific options:
46
- # -H, --drb-server-host HOST Specify DRb Server interface to host on
47
- # -d, --drb-server-port PORT Specify DRb Server port to listen on
48
- # -h, --ring-server-host HOST Specify Ring Server host to connect to
49
- # -r, --ring-server-port PORT Specify Ring Server port to broadcast on
50
- # -b, --browser-type TYPE Specify browser type to register {ie|firefox|safari}
51
- # -a, --access-control-list ACLS Specify a comma separated Access Control List
52
- # -l, --log-level LEVEL Specify log level {DEBUG|INFO|ERROR}
53
- # --help Show this message
54
-
55
- === Default
56
- To start a controller with default settings:
57
- $ provider
58
-
59
- This will bind the provider to your external facing interface attempt to find the ring server on the default port of 12358
60
- e.g.
61
- DRb server started on : druby://143.238.105.61:11236
62
- Ring server found on : druby://143.238.105.61:12358
63
- New tuple registered : druby://143.238.105.61:12358
64
-
65
- === Start on specific interface or ports
66
- To start a provider on specific interfaces or ports:
67
- $ provider -r 12358 -h 143.238.105.61
68
-
69
- This will attempt to find the ring server on the port and hostname specifed
70
- e.g.
71
- DRb server started on : druby://143.238.105.61:11236
72
- Ring server found on : druby://143.238.105.61:12358
73
- New tuple registered : druby://143.238.105.61:12358
74
-
75
- === Start with access control list
76
- To start a controller with an access control list:
77
- $ provider -a deny,all,allow,127.0.0.1
78
-
79
- This will deny all access by default and allow access to this provider on localhost only.
80
-
81
- === Start with a specific browser supported
82
- By default, the provider will try to instantiate a browser object based on availability with your operating system e.g. Internet Explorer, Firefox or Safari. You can force provision of a set browser type as follows:
83
- $ provider -b safari
84
-
85
- This will provide a Safari browser object. Other options are:
86
- $ provider -b ie
87
- $ provider -b firefox
88
-
89
- == Consuming Browser Objects on the Grid
90
- Watir has been extended with a Grid class that can be used as follows:
91
- require 'rubygems'
92
- require 'watirgrid'
93
-
94
- grid = Watir::Grid.new(:ring_server_port => 12358)
95
- grid.start(:quantity => 1, :read_all => true, :browser_type => 'ie')
96
- threads = []
97
- grid.browsers.each do |browser|
98
- threads << Thread.new do
99
- b = browser[:object].new_browser
100
- b.goto("http://www.google.com")
101
- b.text_field(:name, 'q').set("watirgrid")
102
- b.button(:name, "btnI").click
103
- end
104
- end
105
- threads.each {|thread| thread.join}
106
-
107
- Stepping through this example we first instantiate a browsers object, specifying which ring server port to broadcast on when looking for available providers:
108
- grid = Watir::Grid.new(:ring_server_port => 12358)
109
-
110
- You may also need to tell the code which host the ring server is on:
111
- grid = Watir::Grid.new(:ring_server_port => 12358, :ring_server_host => 143.238.105.61)
112
-
113
- Next we start up the grid, specifying the number of browsers we wish to use, and the method of accessing the tuple space:
114
- grid.start(:quantity => 1, :read_all => true)
115
-
116
- There are two methods for accessing the tuple space.
117
- :read_all => true
118
- :take_all => true
119
- *Read* *All* will read all browsers in the tuple space provided by the providers. This leaves the tuple open to other clients.
120
-
121
- *Take* *All* will take all browsers in the tuple space in a destructive manner. That is, once a tuple has been taken, no other clients will be able to re-use that tuple. This is useful if you do not want concurrent access to the same host, for example, multiple browsers running on the one machine.
122
-
123
- The quantity attribute will determine how many browsers are accessed.
124
- :quantity => 10
125
- Will attempt to access 10 tuples if they are available.
126
-
127
- Other attributes include:
128
- :hostnames => { "localhost" => "127.0.0.1"}
129
- Will determine which providers identified by a hash of hostnames that should be accessed. Useful if trying to limit the test to run from specific hostnames or IP addresses.
130
-
131
- :browser_type => 'firefox'
132
- Will determine which providers identified by a browser type should be accessed. Useful if trying to to test with specific browser types.
@@ -1,54 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe 'Utility Functions for the Grid' do
4
- before(:all) do
5
- @controller = Controller.new(
6
- :ring_server_port => 12353,
7
- :loglevel => Logger::ERROR)
8
- @controller.start
9
- 1.upto(1) do
10
- provider = Provider.new(
11
- :ring_server_port => 12353,
12
- :loglevel => Logger::ERROR, :browser_type => 'safari')
13
- provider.start
14
- end
15
- grid = Watir::Grid.new(:ring_server_port => 12353)
16
- grid.start(:read_all => true)
17
- @browser = grid.browsers[0]
18
- end
19
-
20
- after(:all) do
21
- @controller.stop
22
- end
23
-
24
- it 'should get the logged-in user for the remote provider' do
25
- @browser[:object].get_logged_in_user.should == `whoami`.chomp
26
- end
27
-
28
- it 'should enumerate any running browsers on the remote provider' do
29
- @browser[:object].get_running_browsers(['firefox-bin']).size.should == 0
30
- end
31
-
32
- it 'should be able to start a new firefox browser' do
33
- @browser[:object].start_firefox_jssh
34
- sleep 5
35
- @browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
36
- end
37
-
38
- it 'should be able to kill all firefox browsers' do
39
- @browser[:object].kill_browser('firefox-bin')
40
- @browser[:object].get_running_browsers(['firefox-bin']).size.should == 0
41
- end
42
-
43
- it 'should be able to start a new firefox browser specified by path' do
44
- @browser[:object].start_firefox_jssh
45
- ("/Applications/Firefox.app/Contents/MacOS/firefox-bin")
46
- sleep 5
47
- @browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
48
- end
49
-
50
- it 'should be able to kill all browsers' do
51
- @browser[:object].kill_all_browsers
52
- @browser[:object].get_running_browsers.size.should == 0
53
- end
54
- end
@@ -1,60 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
3
-
4
- describe 'Using the Grid with WebDriver Remote' do
5
- before(:all) do
6
- @controller = Controller.new(
7
- :loglevel => Logger::ERROR)
8
- @controller.start
9
- provider = Provider.new(
10
- :loglevel => Logger::ERROR, :browser_type => 'webdriver_remote')
11
- provider.start
12
- end
13
-
14
- after(:all) do
15
- @controller.stop
16
- end
17
-
18
- it 'should read the provider on the grid and execute some Watir code in WebDriver with HtmlUnit' do
19
- grid = Watir::Grid.new
20
- grid.start(:quantity => 1, :read_all => true)
21
- threads = []
22
- grid.browsers.each do |browser|
23
- threads << Thread.new do
24
- b = browser[:object].new_browser(:htmlunit)
25
- b.goto("http://www.google.com")
26
- b.text_field(:name, 'q').set("watirgrid")
27
- b.button(:name, "btnI").click
28
- b.close
29
- end
30
- end
31
- threads.each {|thread| thread.join}
32
- grid.size.should == 1
33
- end
34
-
35
- it 'should read the provider on the grid and execute some Watir code in WebDriver with HtmlUnit' do
36
- grid = Watir::Grid.new
37
- grid.start(:quantity => 1, :read_all => true)
38
- threads = []
39
- grid.browsers.each do |browser|
40
- threads << Thread.new do
41
- vusers = []
42
- 3.times do
43
- vusers << Thread.new do
44
- b = browser[:object].new_browser(:htmlunit)
45
- b.goto("http://www.google.com")
46
- b.text_field(:name => "q").set "watirgrid"
47
- b.button(:name => "btnG").click
48
- b.div(:id => "resultStats").wait_until_present
49
- p "Displaying page: '#{b.title}' with results: '#{b.div(:id => "resultStats").text}'"
50
- b.close
51
- end
52
- vusers.each {|vuser| vuser.join}
53
- end
54
- end
55
- end
56
- threads.each {|thread| thread.join}
57
- grid.size.should == 1
58
- end
59
-
60
- end