testingbot 0.0.6 → 0.0.7

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.
@@ -26,12 +26,12 @@ You can find an example in our examples folder, try something like this:
26
26
 
27
27
  def setup
28
28
  @browser = Selenium::Client::Driver.new \
29
- :host => "http://hub.testingbot.com",
29
+ :host => "hub.testingbot.com",
30
30
  :port => 4444,
31
- :browser => "*safari",
31
+ :browser => "firefox",
32
32
  :url => "http://www.google.com",
33
33
  :platform => "WINDOWS",
34
- :version => 6,
34
+ :version => 10,
35
35
  :timeout_in_second => 60
36
36
 
37
37
  browser.options = {
@@ -51,25 +51,65 @@ You can find an example in our examples folder, try something like this:
51
51
  end
52
52
  end
53
53
 
54
- === Example RSpec
55
- This example needs RSpec version 1. You can run it with spec test_rspec.rb
54
+ === Example RSpec 2
55
+ This example uses RSpec 2. You can run it with rspec test_rspec.rb
56
56
 
57
- require "rubygems"
57
+ require 'rubygems'
58
+ require "selenium/client"
59
+ require 'rspec'
60
+ require 'testingbot'
61
+
62
+ describe "Test", :type => :selenium do
63
+ attr_reader :selenium_driver
64
+ before(:all) do
65
+ @selenium_driver = Selenium::Client::Driver.new \
66
+ :host => "hub.testingbot.com",
67
+ :port => 4444,
68
+ :browser => "firefox",
69
+ :url => "http://www.google.com",
70
+ :timeout_in_second => 60,
71
+ :platform => "WINDOWS",
72
+ :version => "10"
73
+ end
74
+
75
+ before(:each) do
76
+ @selenium_driver.start_new_browser_session
77
+ end
78
+
79
+ after(:each) do
80
+ @selenium_driver.close_current_browser_session
81
+ end
82
+
83
+ it "can find the right title" do
84
+ @selenium_driver.open "/"
85
+ @selenium_driver.title.should eql("Google")
86
+ end
87
+ end
88
+
89
+ === Example RSpec 1
90
+ This example uses RSpec 1. You can run it with spec test_rspec1.rb
91
+
92
+ require 'rubygems'
93
+ gem "rspec", "<2"
94
+ gem "selenium-client"
95
+ require "selenium/client"
96
+ require "selenium/rspec/spec_helper"
97
+ gem "testingbot"
58
98
  require "testingbot"
59
99
 
60
- describe "People" do
100
+ describe "Test" do
61
101
  attr_reader :selenium_driver
62
102
  alias :page :selenium_driver
63
-
103
+
64
104
  before(:all) do
65
105
  @selenium_driver = Selenium::Client::Driver.new \
66
- :host => "http://hub.testingbot.com",
106
+ :host => "hub.testingbot.com",
67
107
  :port => 4444,
68
- :browser => "*safari",
69
- :url => "http://www.google.com",
108
+ :browser => "firefox",
109
+ :url => "http://www.google.com",
110
+ :timeout_in_second => 60,
70
111
  :platform => "WINDOWS",
71
- :version => 6,
72
- :timeout_in_second => 60
112
+ :version => "10"
73
113
  end
74
114
 
75
115
  before(:each) do
@@ -86,6 +126,42 @@ This example needs RSpec version 1. You can run it with spec test_rspec.rb
86
126
  end
87
127
  end
88
128
 
129
+ === Example RSpec 2 and Capybara
130
+ This example uses RSpec 2 together with capybara and Selenium webdriver. You can run it with rspec capybara.rb
131
+
132
+ require 'rspec'
133
+ require 'capybara/rspec'
134
+ require 'selenium/webdriver'
135
+ require 'testingbot'
136
+
137
+ RSpec.configure do |config|
138
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox
139
+ caps.version = "8"
140
+ caps.platform = :WINDOWS
141
+
142
+ Capybara.default_driver = :testingbot
143
+ Capybara.register_driver :testingbot do |app|
144
+ client = Selenium::WebDriver::Remote::Http::Default.new
145
+ client.timeout = 120
146
+ Capybara::Selenium::Driver.new(app,
147
+ :browser => :remote,
148
+ :url => "http://key:secret@hub.testingbot.com:4444/wd/hub",
149
+ :http_client => client,
150
+ :desired_capabilities => caps)
151
+ end
152
+ end
153
+
154
+ describe "Test", :type => :request do
155
+ before :all do
156
+ Capybara.app_host = "http://testingbot.com"
157
+ end
158
+
159
+ it 'has a homepage with the word Selenium' do
160
+ visit '/'
161
+ page.should have_content('Selenium')
162
+ end
163
+ end
164
+
89
165
  == Extra options
90
166
  You can specify extra options like enabling/disabling the screenrecording or screenshot feature. (browser.options)
91
167
 
@@ -98,5 +174,5 @@ Get more information on http://www.testingbot.com
98
174
 
99
175
  == Copyright
100
176
 
101
- Copyright (c) 2011 TestingBot
177
+ Copyright (c) 2012 TestingBot
102
178
  Please see our LICENSE
@@ -0,0 +1,3 @@
1
+ Testing with Cucumber, Selenium and Capybara
2
+
3
+ More info at http://testingbot.com/support/getting-started/ruby.html
@@ -0,0 +1,20 @@
1
+ require 'capybara'
2
+ require 'capybara/cucumber'
3
+ require 'rspec'
4
+ require 'selenium/webdriver'
5
+ require 'testingbot/cucumber'
6
+
7
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox
8
+ caps.version = "8"
9
+ caps.platform = :WINDOWS
10
+
11
+ Capybara.default_driver = :testingbot
12
+ Capybara.register_driver :testingbot do |app|
13
+ client = Selenium::WebDriver::Remote::Http::Default.new
14
+ client.timeout = 120
15
+ Capybara::Selenium::Driver.new(app,
16
+ :browser => :remote,
17
+ :url => "http://key:secret@hub.testingbot.com:4444/wd/hub",
18
+ :http_client => client,
19
+ :desired_capabilities => caps)
20
+ end
@@ -0,0 +1,9 @@
1
+ Feature: YouTube has a search function.
2
+
3
+ Background:
4
+ Given I am on YouTube
5
+
6
+ Scenario: Search for a term
7
+ When I fill in "search_query" with "text adventure"
8
+ And I press "search-btn"
9
+ Then I should see "GET LAMP: The Text Adventure Documentary"
@@ -0,0 +1,15 @@
1
+ Given /^I am on (.+)$/ do |url|
2
+ visit "http://www.youtube.com"
3
+ end
4
+
5
+ When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
6
+ fill_in(field, :with => value)
7
+ end
8
+
9
+ When /^I press "([^"]*)"$/ do |button|
10
+ click_button(button)
11
+ end
12
+
13
+ Then /^I should see "([^"]*)"$/ do |text|
14
+ page.should have_content(text)
15
+ end
@@ -14,15 +14,15 @@ class ExampleTest < TestingBot::TestCase
14
14
  @browser = Selenium::Client::Driver.new \
15
15
  :host => "hub.testingbot.com",
16
16
  :port => 4444,
17
- :browser => "iexplore",
17
+ :browser => "firefox",
18
18
  :platform => "WINDOWS",
19
- :version => "7",
20
- :url => "http://www.google.com",
19
+ :version => "10",
20
+ :url => "http://testingbot.com",
21
21
  :timeout_in_second => 60
22
22
 
23
23
  browser.extra = "First test" # some custom data you can pass with your tests
24
24
 
25
- browser.start_new_browser_session
25
+ browser.start_new_browser_session(:captureNetworkTraffic => true)
26
26
  end
27
27
 
28
28
  def teardown
@@ -31,6 +31,7 @@ class ExampleTest < TestingBot::TestCase
31
31
 
32
32
  def test_page_search
33
33
  browser.open "/"
34
- assert_equal "Google", browser.title
34
+ # assert_equal "Google", browser.title
35
+ p browser.browser_network_traffic
35
36
  end
36
- end
37
+ end
@@ -116,27 +116,29 @@ begin
116
116
  if !@selenium_driver.nil?
117
117
  session_id = @selenium_driver.session_id_backup
118
118
  elsif defined?(Capybara)
119
- session_id = Capybara.drivers[:testingbot].call.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
120
- end
121
-
122
- if session_id.nil?
123
- return
119
+ begin
120
+ session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
121
+ rescue Exception => e
122
+ p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
123
+ end
124
124
  end
125
125
 
126
- params = {
127
- "session_id" => session_id,
128
- "client_key" => client_key,
129
- "client_secret" => client_secret,
130
- "status_message" => @execution_error,
131
- "success" => !actual_failure?,
132
- "name" => description.to_s,
133
- "kind" => 2,
134
- "extra" => @selenium_driver.extra
135
- }
126
+ if !session_id.nil?
127
+ params = {
128
+ "session_id" => session_id,
129
+ "client_key" => client_key,
130
+ "client_secret" => client_secret,
131
+ "status_message" => @execution_error,
132
+ "success" => !actual_failure?,
133
+ "name" => description.to_s,
134
+ "kind" => 2,
135
+ "extra" => @selenium_driver.extra
136
+ }
136
137
 
137
- url = URI.parse('http://testingbot.com/hq')
138
- http = Net::HTTP.new(url.host, url.port)
139
- response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
138
+ url = URI.parse('http://testingbot.com/hq')
139
+ http = Net::HTTP.new(url.host, url.port)
140
+ response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
141
+ end
140
142
  else
141
143
  puts "Can't post test results to TestingBot since I could not a .testingbot file in your home-directory."
142
144
  end
@@ -150,6 +152,7 @@ begin
150
152
  require 'rspec'
151
153
 
152
154
  ::RSpec.configuration.after :each do
155
+ p
153
156
  if File.exists?(File.expand_path("~/.testingbot"))
154
157
  str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
155
158
  client_key, client_secret = str.split(':')
@@ -166,30 +169,32 @@ begin
166
169
  if !@selenium_driver.nil?
167
170
  session_id = @selenium_driver.session_id_backup
168
171
  elsif defined?(Capybara)
169
- session_id = Capybara.drivers[:testingbot].call.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
170
- end
171
-
172
- if session_id.nil?
173
- return
172
+ begin
173
+ session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
174
+ rescue Exception => e
175
+ p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
176
+ end
174
177
  end
175
178
 
176
- params = {
177
- "session_id" => session_id,
178
- "client_key" => client_key,
179
- "client_secret" => client_secret,
180
- "status_message" => @execution_error,
181
- "success" => example.exception.nil?,
182
- "name" => test_name,
183
- "kind" => 2
184
- }
179
+ if !session_id.nil?
180
+ params = {
181
+ "session_id" => session_id,
182
+ "client_key" => client_key,
183
+ "client_secret" => client_secret,
184
+ "status_message" => @execution_error,
185
+ "success" => example.exception.nil?,
186
+ "name" => test_name,
187
+ "kind" => 2
188
+ }
185
189
 
186
- if @selenium_driver && @selenium_driver.extra
187
- params["extra"] = @selenium_driver.extra
188
- end
190
+ if @selenium_driver && @selenium_driver.extra
191
+ params["extra"] = @selenium_driver.extra
192
+ end
189
193
 
190
- url = URI.parse('http://testingbot.com/hq')
191
- http = Net::HTTP.new(url.host, url.port)
192
- response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
194
+ url = URI.parse('http://testingbot.com/hq')
195
+ http = Net::HTTP.new(url.host, url.port)
196
+ response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
197
+ end
193
198
  else
194
199
  puts "Can't post test results to TestingBot since I could not a .testingbot file in your home-directory."
195
200
  end
@@ -1,3 +1,3 @@
1
1
  module Testingbot
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testingbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000 Z
12
+ date: 2012-02-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem makes using our Selenium grid on testingbot.com easy
15
15
  email:
@@ -26,6 +26,10 @@ files:
26
26
  - Rakefile
27
27
  - bin/testingbot
28
28
  - examples/capybara.rb
29
+ - examples/cucumber/README
30
+ - examples/cucumber/features/support/env.rb
31
+ - examples/cucumber/features/youtube.feature
32
+ - examples/cucumber/features/youtube_steps.rb
29
33
  - examples/test_rspec.rb
30
34
  - examples/test_rspec1.rb
31
35
  - examples/test_unit.rb