testingbot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -22,6 +22,7 @@ Type testingbot in your commandline and fill in the API key and API secret you o
22
22
  You can find an example in our examples folder, try something like this:
23
23
 
24
24
  require "rubygems"
25
+ require "test/unit"
25
26
  require "testingbot"
26
27
  class ExampleTest < TestingBot::TestCase
27
28
  attr_reader :browser
@@ -138,7 +139,7 @@ This example uses RSpec 2 together with capybara and Selenium webdriver. You can
138
139
  end
139
140
 
140
141
  describe "People", :type => :request do
141
- before :all do
142
+ before :each do
142
143
  Capybara.current_driver = :testingbot
143
144
  Capybara.app_host = "http://testingbot.com"
144
145
  end
@@ -171,12 +172,18 @@ Add the example below in spec/integration/home_spec.rb
171
172
  end
172
173
 
173
174
  describe 'home page' do
174
- before :all do
175
+ before :each do
175
176
  Capybara.server_port = 3011
176
177
  Capybara.current_driver = :testingbot
177
178
  Capybara.app_host = "http://127.0.0.1:3011"
178
179
  end
179
180
 
181
+ after :each do
182
+ # this is a workaround to push test status/details back to testingbot
183
+ # we need to use this because capybara overwrites the driver with a rack-test driver
184
+ @selenium_driver = page.driver.browser.send(:bridge)
185
+ end
186
+
180
187
  it "shows the home page", :type => :request do
181
188
  visit '/'
182
189
  page.should have_content('Selenium')
@@ -185,6 +192,7 @@ Add the example below in spec/integration/home_spec.rb
185
192
 
186
193
  === Example RSpec 2 run on multiple browsers
187
194
  Use the :multibrowser => true statement to indicate you want to test on multiple browsers.
195
+ This should work together with Capybara as well.
188
196
 
189
197
  require 'rubygems'
190
198
  require "selenium/client"
data/examples/android.rb CHANGED
@@ -4,11 +4,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/config.rb'
4
4
  require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/selenium.rb')
5
5
 
6
6
  TestingBot::config do |config|
7
- config[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.android
7
+ config[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.iphone
8
+ #config[:desired_capabilities] = { "platform" => "ANDROID", "browserName" => "galaxytab" }
8
9
  end
9
10
 
10
11
  driver = TestingBot::SeleniumWebdriver.new
11
12
 
12
- driver.navigate.to "http://testingbot.com/"
13
+ driver.navigate.to "http://www.google.com"
13
14
  puts driver.title
14
- driver.quit
15
+ #sleep 140
16
+ driver.quit
data/examples/capybara.rb CHANGED
@@ -4,12 +4,11 @@ require 'testingbot'
4
4
  require 'testingbot/capybara'
5
5
 
6
6
  TestingBot::config do |config|
7
- config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
8
- config[:options] = { :screenshot => false, :extra => "Some extra data" }
7
+ config[:desired_capabilities] = [{ :browserName => "internet explorer", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
9
8
  #config.require_tunnel
10
9
  end
11
10
 
12
- describe "People", :type => :request do
11
+ describe "People", :type => :request, :multibrowser => true do
13
12
  before :all do
14
13
  Capybara.current_driver = :testingbot
15
14
  Capybara.app_host = "http://testingbot.com"
@@ -17,6 +16,9 @@ describe "People", :type => :request do
17
16
 
18
17
  it 'has a homepage with the word Selenium' do
19
18
  visit '/'
19
+ #sleep 150
20
+ p "inspect"
21
+ p page.inspect
20
22
  page.should have_content('Selenium')
21
23
  end
22
- end
24
+ end
@@ -5,7 +5,7 @@ require 'testingbot'
5
5
  require 'testingbot/tunnel'
6
6
 
7
7
  TestingBot::config do |config|
8
- config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
8
+ config[:desired_capabilities] = [{ :browserName => "chrome", :platform => "WINDOWS" }]
9
9
  end
10
10
 
11
11
  # rspec 2
@@ -14,4 +14,4 @@ describe "People", :type => :selenium, :multibrowser => true do
14
14
  page.navigate.to "http://www.google.com"
15
15
  page.title.should eql("Google")
16
16
  end
17
- end
17
+ end
@@ -17,13 +17,18 @@ module TestingBot
17
17
  end
18
18
 
19
19
  class CustomDriver < ::Capybara::Selenium::Driver
20
+
21
+ def session_id
22
+ @browser.session_id
23
+ end
24
+
20
25
  def browser
21
26
  unless @browser
22
27
  if TestingBot.get_config[:require_tunnel]
23
28
  TestingBot::Capybara.start_tunnel
24
29
  end
25
30
 
26
- @browser = TestingBot::SeleniumWebdriver.new
31
+ @browser = TestingBot::SeleniumWebdriver.new(@options || {})
27
32
 
28
33
  main = Process.pid
29
34
  at_exit do
@@ -44,6 +49,18 @@ module TestingBot
44
49
  end
45
50
  end
46
51
 
52
+ module Capybara
53
+ class Session
54
+ def stop
55
+ driver.quit
56
+ end
57
+
58
+ def session_id
59
+ driver.session_id
60
+ end
61
+ end
62
+ end
63
+
47
64
  Capybara.register_driver :testingbot do |app|
48
65
  TestingBot::Capybara::CustomDriver.new(app)
49
66
  end
@@ -78,7 +78,17 @@ begin
78
78
  base.around do |test|
79
79
  if TestingBot.get_config.desired_capabilities.instance_of?(Array)
80
80
  TestingBot.get_config.desired_capabilities.each do |browser|
81
- @selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => browser })
81
+
82
+ if defined?(Capybara)
83
+ ::Capybara.register_driver :multibrowser do |app|
84
+ TestingBot::Capybara::CustomDriver.new(app, { :desired_capabilities => browser })
85
+ end
86
+
87
+ @selenium_driver = ::Capybara::Session.new(:multibrowser)
88
+ else
89
+ @selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => browser })
90
+ end
91
+
82
92
  begin
83
93
  test.run
84
94
  ensure
@@ -86,7 +96,11 @@ begin
86
96
  end
87
97
  end
88
98
  else
89
- @selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => TestingBot.get_config.desired_capabilities })
99
+ if defined?(Capybara)
100
+ @selenium_driver = ::Capybara::Session.new(:testingbot)
101
+ else
102
+ @selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => TestingBot.get_config.desired_capabilities })
103
+ end
90
104
  begin
91
105
  test.run
92
106
  ensure
@@ -167,6 +181,13 @@ begin
167
181
  rescue Exception => e
168
182
  p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
169
183
  end
184
+
185
+ if session_id.nil? || session_id.empty?
186
+ begin
187
+ session_id = page.driver.browser.send(:bridge).session_id
188
+ rescue
189
+ end
190
+ end
170
191
  end
171
192
 
172
193
  if !session_id.nil?
@@ -16,6 +16,10 @@ module TestingBot
16
16
  @options = @options.merge(options)
17
17
 
18
18
  http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
19
+ if ENV['TESTINGBOT_CLIENT_PROXY']
20
+ require 'ostruct'
21
+ http_client.proxy = OpenStruct.new(:http => ENV['TESTINGBOT_CLIENT_PROXY'])
22
+ end
19
23
  http_client.timeout = 400
20
24
  @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@options[:client_key]}:#{@options[:client_secret]}@#{@options[:host]}:#{@options[:port]}/wd/hub", :desired_capabilities => @options[:desired_capabilities], :http_client => http_client)
21
25
  http_client.timeout = 120
@@ -1,3 +1,3 @@
1
1
  module Testingbot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-09 00:00:00.000000000 Z
12
+ date: 2012-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70361245219640 !ruby/object:Gem::Requirement
16
+ requirement: &70309646999820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70361245219640
24
+ version_requirements: *70309646999820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: net-http-persistent
27
- requirement: &70361253323120 !ruby/object:Gem::Requirement
27
+ requirement: &70309646999400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70361253323120
35
+ version_requirements: *70309646999400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: selenium-webdriver
38
- requirement: &70361253322700 !ruby/object:Gem::Requirement
38
+ requirement: &70309646998980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70361253322700
46
+ version_requirements: *70309646998980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70361253322180 !ruby/object:Gem::Requirement
49
+ requirement: &70309646998460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.9.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70361253322180
57
+ version_requirements: *70309646998460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70361253321760 !ruby/object:Gem::Requirement
60
+ requirement: &70309646998040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70361253321760
68
+ version_requirements: *70309646998040
69
69
  description: This gem makes using our Selenium grid on testingbot.com easy
70
70
  email:
71
71
  - info@testingbot.com