watirgrid 1.1.0 → 1.1.1
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/Rakefile +1 -1
- data/lib/provider.rb +16 -2
- data/lib/watirgrid.rb +2 -14
- data/spec/control_spec.rb +27 -0
- data/spec/webdriver_remote_spec.rb +29 -4
- data/watirgrid.gemspec +2 -2
- metadata +6 -7
- data/lib/extensions/remote.rb +0 -39
- data/spec/gridinit_spec.rb +0 -63
data/Rakefile
CHANGED
|
@@ -9,7 +9,7 @@ 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.
|
|
12
|
+
gem.version = "1.1.1"
|
|
13
13
|
end
|
|
14
14
|
rescue LoadError
|
|
15
15
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
data/lib/provider.rb
CHANGED
|
@@ -37,6 +37,10 @@ module Watir
|
|
|
37
37
|
require 'watir-webdriver'
|
|
38
38
|
require 'watir-webdriver-performance'
|
|
39
39
|
@browser = Watir::Browser
|
|
40
|
+
when :webdriver_remote
|
|
41
|
+
require 'watir-webdriver'
|
|
42
|
+
require 'selenium-webdriver'
|
|
43
|
+
@browser = Watir::Browser
|
|
40
44
|
when :selenium
|
|
41
45
|
require 'selenium-webdriver'
|
|
42
46
|
@browser = Selenium::WebDriver
|
|
@@ -46,9 +50,19 @@ module Watir
|
|
|
46
50
|
def new_browser(webdriver_browser_type = :firefox)
|
|
47
51
|
case @browser.inspect
|
|
48
52
|
when "Selenium::WebDriver"
|
|
49
|
-
|
|
53
|
+
if webdriver_browser_type == :htmlunit
|
|
54
|
+
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
|
|
55
|
+
@browser.for(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)
|
|
56
|
+
else
|
|
57
|
+
@browser.for webdriver_browser_type
|
|
58
|
+
end
|
|
50
59
|
when "Watir::Browser"
|
|
51
|
-
|
|
60
|
+
if webdriver_browser_type == :htmlunit
|
|
61
|
+
caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
|
|
62
|
+
@browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)
|
|
63
|
+
else
|
|
64
|
+
@browser.new webdriver_browser_type
|
|
65
|
+
end
|
|
52
66
|
when "Watir::Safari"
|
|
53
67
|
@browser.new
|
|
54
68
|
when "FireWatir::Firefox"
|
data/lib/watirgrid.rb
CHANGED
|
@@ -50,33 +50,21 @@ module Watir
|
|
|
50
50
|
|
|
51
51
|
##
|
|
52
52
|
# This is a helper method to control a grid.
|
|
53
|
-
# It involves some general block thuggery and could
|
|
54
|
-
# honestly benefit from some brutal refactoring...
|
|
55
53
|
def self.control(params = {}, &block)
|
|
56
54
|
log = Logger.new(STDOUT, 'daily')
|
|
57
55
|
log.level = params[:loglevel] || Logger::ERROR
|
|
58
56
|
grid = self.new(params)
|
|
59
|
-
grid.start(:
|
|
60
|
-
log.debug("Grid size : #{grid.size}")
|
|
61
|
-
log.debug("Grid rampup : #{rampup(grid.size, params)} secs")
|
|
57
|
+
grid.start(:read_all => true)
|
|
62
58
|
threads = []
|
|
63
59
|
grid.browsers.each_with_index do |browser, index|
|
|
64
60
|
sleep rampup(grid.size, params)
|
|
65
61
|
threads << Thread.new do
|
|
66
62
|
start = ::Time.now
|
|
67
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} start : #{::Time.now}")
|
|
68
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} architecture : #{browser[:architecture]}")
|
|
69
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} type : #{browser[:browser_type]}")
|
|
70
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} hostname : #{browser[:hostname]}")
|
|
71
63
|
@browser = browser[:object].new_browser
|
|
72
|
-
yield @browser, "#{index
|
|
73
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} stop : #{::Time.now}")
|
|
74
|
-
log.debug("Browser #{index+1}##{Thread.current.object_id} elapsed : #{(::Time.now - start).to_i} secs")
|
|
75
|
-
#@browser.close
|
|
64
|
+
yield @browser, "#{index}"
|
|
76
65
|
end
|
|
77
66
|
end
|
|
78
67
|
threads.each {|thread| thread.join}
|
|
79
|
-
grid.release_tuples
|
|
80
68
|
end
|
|
81
69
|
|
|
82
70
|
private
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe 'Using the Grid Control method' do
|
|
4
|
+
before(:all) do
|
|
5
|
+
@controller = Controller.new(
|
|
6
|
+
:ring_server_port => 12357,
|
|
7
|
+
:loglevel => Logger::ERROR)
|
|
8
|
+
@controller.start
|
|
9
|
+
provider = Provider.new(
|
|
10
|
+
:ring_server_port => 12357,
|
|
11
|
+
:loglevel => Logger::ERROR, :browser_type => 'safari')
|
|
12
|
+
provider.start
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:all) do
|
|
16
|
+
@controller.stop
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should control a grid' do
|
|
20
|
+
Watir::Grid.control(:ring_server_port => 12357) do |browser, index|
|
|
21
|
+
p "I am browser index #{index}"
|
|
22
|
+
browser.goto "google.com"
|
|
23
|
+
p browser.title
|
|
24
|
+
browser.close
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
|
3
|
-
require 'extensions/remote'
|
|
4
3
|
|
|
5
4
|
describe 'Using the Grid with WebDriver Remote' do
|
|
6
5
|
before(:all) do
|
|
@@ -16,12 +15,12 @@ describe 'Using the Grid with WebDriver Remote' do
|
|
|
16
15
|
@controller.stop
|
|
17
16
|
end
|
|
18
17
|
|
|
19
|
-
it 'should
|
|
18
|
+
it 'should read the provider on the grid and execute some Watir code in WebDriver with HtmlUnit' do
|
|
20
19
|
grid = Watir::Grid.new
|
|
21
|
-
grid.start(:quantity => 1, :
|
|
20
|
+
grid.start(:quantity => 1, :read_all => true)
|
|
22
21
|
threads = []
|
|
23
22
|
grid.browsers.each do |browser|
|
|
24
|
-
threads << Thread.new do
|
|
23
|
+
threads << Thread.new do
|
|
25
24
|
b = browser[:object].new_browser(:htmlunit)
|
|
26
25
|
b.goto("http://www.google.com")
|
|
27
26
|
b.text_field(:name, 'q').set("watirgrid")
|
|
@@ -32,4 +31,30 @@ describe 'Using the Grid with WebDriver Remote' do
|
|
|
32
31
|
threads.each {|thread| thread.join}
|
|
33
32
|
grid.size.should == 1
|
|
34
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
|
+
|
|
35
60
|
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.0
|
|
8
|
+
s.version = "1.1.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Tim Koopmans"]
|
|
12
|
-
s.date = %q{2011-04-
|
|
12
|
+
s.date = %q{2011-04-20}
|
|
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"]
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watirgrid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 17
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 1
|
|
9
|
-
-
|
|
10
|
-
version: 1.1.
|
|
9
|
+
- 1
|
|
10
|
+
version: 1.1.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Tim Koopmans
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-04
|
|
18
|
+
date: 2011-05-04 00:00:00 +10:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|
|
@@ -45,13 +45,12 @@ files:
|
|
|
45
45
|
- examples/cucumber/example.feature
|
|
46
46
|
- examples/cucumber/step_definitions/example_steps.rb
|
|
47
47
|
- lib/controller.rb
|
|
48
|
-
- lib/extensions/remote.rb
|
|
49
48
|
- lib/listener.rb
|
|
50
49
|
- lib/provider.rb
|
|
51
50
|
- lib/watirgrid.rb
|
|
52
51
|
- rdoc/logo.png
|
|
52
|
+
- spec/control_spec.rb
|
|
53
53
|
- spec/grid_spec.rb
|
|
54
|
-
- spec/gridinit_spec.rb
|
|
55
54
|
- spec/memory_spec.rb
|
|
56
55
|
- spec/selenium_webdriver_spec.rb
|
|
57
56
|
- spec/spec_helper.rb
|
|
@@ -98,8 +97,8 @@ test_files:
|
|
|
98
97
|
- examples/basic/example_webdriver.rb
|
|
99
98
|
- examples/basic/example_webdriver_remote.rb
|
|
100
99
|
- examples/cucumber/step_definitions/example_steps.rb
|
|
100
|
+
- spec/control_spec.rb
|
|
101
101
|
- spec/grid_spec.rb
|
|
102
|
-
- spec/gridinit_spec.rb
|
|
103
102
|
- spec/memory_spec.rb
|
|
104
103
|
- spec/selenium_webdriver_spec.rb
|
|
105
104
|
- spec/spec_helper.rb
|
data/lib/extensions/remote.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# remote.rb
|
|
3
|
-
# Rinda Ring Provider
|
|
4
|
-
|
|
5
|
-
require 'rinda/ring'
|
|
6
|
-
require 'rinda/tuplespace'
|
|
7
|
-
require 'logger'
|
|
8
|
-
require 'drb/acl'
|
|
9
|
-
require 'uuid'
|
|
10
|
-
require 'selenium/server'
|
|
11
|
-
include Selenium
|
|
12
|
-
@server = Selenium::Server.new(File.expand_path(File.dirname(__FILE__)) + '/selenium-server-standalone-2.0b1.jar', :background => true)
|
|
13
|
-
@server.start
|
|
14
|
-
|
|
15
|
-
module Watir
|
|
16
|
-
class Provider
|
|
17
|
-
|
|
18
|
-
include DRbUndumped # all objects will be proxied, not copied
|
|
19
|
-
|
|
20
|
-
attr_reader :browser
|
|
21
|
-
|
|
22
|
-
def initialize(browser = nil)
|
|
23
|
-
browser = (browser || 'tmp').downcase.to_sym
|
|
24
|
-
case browser
|
|
25
|
-
when :webdriver_remote
|
|
26
|
-
require 'watir-webdriver'
|
|
27
|
-
@browser = Watir::Browser
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def new_browser(webdriver_browser_type = nil)
|
|
32
|
-
if webdriver_browser_type == :htmlunit
|
|
33
|
-
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
|
|
34
|
-
@browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => capabilities)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
data/spec/gridinit_spec.rb
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
-
|
|
3
|
-
describe 'Using the Grid in GRIDinit style' do
|
|
4
|
-
before(:all) do
|
|
5
|
-
@controller = Controller.new(
|
|
6
|
-
:drb_server_port => 12357,
|
|
7
|
-
:ring_server_port => 12358,
|
|
8
|
-
:ring_server_host => '127.0.0.1',
|
|
9
|
-
:loglevel => Logger::ERROR)
|
|
10
|
-
@controller.start
|
|
11
|
-
1.upto(5) do
|
|
12
|
-
provider = Provider.new(
|
|
13
|
-
:ring_server_port => 12358,
|
|
14
|
-
:ring_server_host => '127.0.0.1',
|
|
15
|
-
:drb_server_host => '127.0.0.1',
|
|
16
|
-
:loglevel => Logger::ERROR,
|
|
17
|
-
:browser_type => 'webdriver')
|
|
18
|
-
provider.start
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
after(:all) do
|
|
23
|
-
@controller.stop
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'should take 1 provider via a direct controller_uri' do
|
|
27
|
-
grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
|
|
28
|
-
:drb_server_host => '127.0.0.1')
|
|
29
|
-
grid.start(:quantity => 3, :take_all => true, :browser_type => 'webdriver')
|
|
30
|
-
grid.size.should == 3
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'should control the grid using a helper method' do
|
|
34
|
-
Watir::Grid.control({:controller_uri => 'druby://127.0.0.1:12357',:loglevel => Logger::DEBUG}) do |browser, id|
|
|
35
|
-
3.times do |iteration|
|
|
36
|
-
browser.goto "http://127.0.0.1/#id=#{id}&iter=#{iteration}"
|
|
37
|
-
sleep 0.5
|
|
38
|
-
end
|
|
39
|
-
browser.close
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'should take all remaining providers via a direct controller_uri' do
|
|
44
|
-
grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
|
|
45
|
-
:drb_server_host => '127.0.0.1')
|
|
46
|
-
grid.start(:take_all => true, :browser_type => 'webdriver')
|
|
47
|
-
grid.size.should == 2
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'should add new providers via a direct controller_uri' do
|
|
51
|
-
provider = Provider.new(
|
|
52
|
-
:controller_uri => 'druby://127.0.0.1:12357',
|
|
53
|
-
:drb_server_host => '127.0.0.1',
|
|
54
|
-
:loglevel => Logger::ERROR,
|
|
55
|
-
:browser_type => 'webdriver')
|
|
56
|
-
provider.start
|
|
57
|
-
grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
|
|
58
|
-
:drb_server_host => '127.0.0.1')
|
|
59
|
-
grid.start(:take_all => true, :browser_type => 'webdriver')
|
|
60
|
-
grid.size.should == 1
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|