watirgrid 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
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.1"
12
+ gem.version = "1.1.2"
13
13
  end
14
14
  rescue LoadError
15
15
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
@@ -1,17 +1,11 @@
1
- @Example
2
- Feature: Watirgrid using WebDriver
3
- In order to use Watirgrid
4
- Users must be able to create controllers, add providers and control a grid
1
+ @NFR-001
2
+ Feature: User logons
3
+ In order to use the web application users must be
4
+ able to logon and access the portal in 3 seconds
5
5
 
6
- Scenario: Create a Controller with Providers
7
- Given I have created and started a Controller
8
- Then I should be able to create and start 2 "WebDriver" Providers
9
-
10
- # Note: WebDriver can only control one instance of any particular browser on a single host.
11
- # With Watirgrid, you'd typically have multiple instances across multiple hosts (Providers)
12
- # For the sake of a demo, we'll just control 2 difference instances on a single host.
13
- Scenario: Create a Grid and control the Providers
14
- Given I have created and started a Grid with 2 Providers
15
- Then I should be able to control the following browsers in parallel:
16
- | Chrome |
17
- | Firefox |
6
+ Scenario: Logon with 50 users in 1 minute
7
+ Given 50 users open "chrome"
8
+ And navigate to the portal
9
+ When they enter their credentials
10
+ Then they should see their account settings
11
+ And the response time should be less than 3 seconds
@@ -1,39 +1,51 @@
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 'rspec/expectations';
4
+ require 'rspec/expectations';
5
+ require 'watir-webdriver-performance'
5
6
 
6
- Given /^I have created and started a Controller$/ do
7
- controller = Controller.new(
8
- :loglevel => Logger::ERROR)
9
- controller.start
7
+ controller = Controller.new(
8
+ :ring_server_port => 12357,
9
+ :loglevel => Logger::ERROR)
10
+ controller.start
11
+
12
+ provider = Provider.new(
13
+ :ring_server_port => 12357,
14
+ :loglevel => Logger::ERROR, :browser_type => 'webdriver')
15
+ provider.start
16
+
17
+ Given /^(\d+) users open "([^"]*)"$/ do |quantity, browser|
18
+ params={}
19
+ params[:ring_server_port] = 12357
20
+ # optionall connect via a controller_uri environment variable
21
+ # params[:controller_uri] = ENV["controller_uri"]
22
+ params[:browser] = browser # type of webdriver browser to spawn
23
+ params[:quantity] = quantity.to_i # max number of browsers to use
24
+ params[:rampup] = 10 # seconds
25
+ @grid = Watir::Grid.new(params)
26
+ @grid.start(:initiate => true)
27
+ end
28
+
29
+ Given /^navigate to the portal$/ do
30
+ @grid.iterate {|browser| browser.goto "http://gridinit.com/examples/logon.html" }
10
31
  end
11
32
 
12
- Then /^I should be able to create and start (\d+) "(.+?)" Providers$/ do |total, browser_type|
13
- 1.upto(total.to_i) do
14
- provider = Provider.new(
15
- :loglevel => Logger::ERROR, :browser_type => browser_type)
16
- provider.start
33
+ When /^they enter their credentials$/ do
34
+ @grid.iterate do |browser|
35
+ browser.text_field(:name => "email").set "tim@mahenterprize.com"
36
+ browser.text_field(:name => "password").set "mahsecretz"
37
+ browser.button(:type => "submit").click
17
38
  end
18
39
  end
19
40
 
20
- Given /^I have created and started a Grid with (\d+) Providers$/ do |total|
21
- @grid = Watir::Grid.new
22
- @grid.start(:take_all => true)
23
- @grid.browsers.size.should == total.to_i
41
+ Then /^they should see their account settings$/ do
42
+ @grid.iterate do |browser|
43
+ browser.text.should =~ /Maybe I should get a real Gridinit account/
44
+ end
24
45
  end
25
46
 
26
- Then /^I should be able to control the following browsers in parallel:$/ do |table|
27
- browsers = table.raw.collect {|e| e.to_s.downcase.to_sym}
28
- threads = []
29
- @grid.browsers.each_with_index do |browser, index|
30
- threads << Thread.new do
31
- b = browser[:object].new_browser(browsers[index])
32
- b.goto("http://www.google.com")
33
- b.text_field(:name, 'q').set("watirgrid")
34
- b.button(:name, "btnI").click
35
- b.close
36
- end
37
- end
38
- threads.each {|thread| thread.join}
47
+ Then /^the response time should be less than (d+) seconds$/ do |response_time|
48
+ @grid.iterate do |browser|
49
+ browser.performance.summary[:response_time].should < response_time.to_i * 1000
50
+ end
39
51
  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, :tuples
13
+ attr_accessor :drb_server_uri, :ring_server, :browsers, :tuples, :providers
14
14
 
15
15
  def initialize(params = {})
16
16
  @drb_server_host = params[:drb_server_host] || external_interface
@@ -23,9 +23,10 @@ module Watir
23
23
  @log = Logger.new(logfile, 'daily')
24
24
  @log.level = params[:loglevel] || Logger::ERROR
25
25
  @log.datetime_format = "%Y-%m-%d %H:%M:%S "
26
-
26
+ @webdriver_browser_type = params[:browser].to_sym if params[:browser]
27
27
  @browsers = []
28
28
  @tuples = []
29
+ @providers = []
29
30
  end
30
31
 
31
32
  ##
@@ -34,6 +35,7 @@ module Watir
34
35
  start_drb_server
35
36
  find_ring_server(params)
36
37
  get_tuples(params)
38
+ setup if params[:initiate]
37
39
  end
38
40
 
39
41
  ##
@@ -48,6 +50,27 @@ module Watir
48
50
  @tuples.each { |tuple| @ring_server.write(tuple) }
49
51
  end
50
52
 
53
+ ##
54
+ # Instantiate new browser object on each of the remote providers
55
+ def setup
56
+ @browsers.each_with_index do |browser, index|
57
+ sleep 0.15
58
+ @providers[index] ||= browser[:object].new_browser(@webdriver_browser_type)
59
+ end
60
+ end
61
+
62
+ ##
63
+ # Iterate with a block over each of the remote providers
64
+ def iterate &block
65
+ threads = []
66
+ @providers.each do |browser|
67
+ threads << Thread.new do
68
+ yield browser
69
+ end
70
+ end
71
+ threads.each {|thread| thread.join}
72
+ end
73
+
51
74
  ##
52
75
  # This is a helper method to control a grid.
53
76
  def self.control(params = {}, &block)
data/spec/control_spec.rb CHANGED
@@ -19,9 +19,18 @@ describe 'Using the Grid Control method' do
19
19
  it 'should control a grid' do
20
20
  Watir::Grid.control(:ring_server_port => 12357) do |browser, index|
21
21
  p "I am browser index #{index}"
22
- browser.goto "google.com"
22
+ browser.goto "http://google.com"
23
23
  p browser.title
24
24
  browser.close
25
25
  end
26
26
  end
27
+
28
+ it 'should iterate over a grid' do
29
+ grid = Watir::Grid.new(:ring_server_port => 12357)
30
+ grid.start(:initiate => true)
31
+ grid.iterate do |browser|
32
+ browser.goto "http://google.com"
33
+ browser.close
34
+ end
35
+ end
27
36
  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.0"
8
+ s.version = "1.1.1"
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-20}
12
+ s.date = %q{2011-05-04}
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"]
@@ -32,13 +32,12 @@ Gem::Specification.new do |s|
32
32
  "examples/cucumber/example.feature",
33
33
  "examples/cucumber/step_definitions/example_steps.rb",
34
34
  "lib/controller.rb",
35
- "lib/extensions/remote.rb",
36
35
  "lib/listener.rb",
37
36
  "lib/provider.rb",
38
37
  "lib/watirgrid.rb",
39
38
  "rdoc/logo.png",
39
+ "spec/control_spec.rb",
40
40
  "spec/grid_spec.rb",
41
- "spec/gridinit_spec.rb",
42
41
  "spec/memory_spec.rb",
43
42
  "spec/selenium_webdriver_spec.rb",
44
43
  "spec/spec_helper.rb",
@@ -56,8 +55,8 @@ Gem::Specification.new do |s|
56
55
  "examples/basic/example_webdriver.rb",
57
56
  "examples/basic/example_webdriver_remote.rb",
58
57
  "examples/cucumber/step_definitions/example_steps.rb",
58
+ "spec/control_spec.rb",
59
59
  "spec/grid_spec.rb",
60
- "spec/gridinit_spec.rb",
61
60
  "spec/memory_spec.rb",
62
61
  "spec/selenium_webdriver_spec.rb",
63
62
  "spec/spec_helper.rb",
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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
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-05-04 00:00:00 +10:00
18
+ date: 2011-05-06 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies: []
21
21