testingbot 0.1.5 → 0.2.2
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.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +26 -0
- data/.travis.yml +7 -3
- data/LICENSE +1 -1
- data/README.md +207 -0
- data/bin/testingbot +4 -3
- data/lib/testingbot.rb +1 -5
- data/lib/testingbot/api.rb +153 -35
- data/lib/testingbot/version.rb +1 -1
- data/spec/integration/api_spec.rb +38 -18
- data/spec/resources/test.apk +1 -0
- data/spec/spec_helper.rb +6 -3
- metadata +55 -94
- data/README.rdoc +0 -237
- data/examples/android.rb +0 -14
- data/examples/capybara.rb +0 -22
- data/examples/capybara_multiple_browsers.rb +0 -38
- data/examples/cucumber/README.rdoc +0 -15
- data/examples/cucumber/Rakefile +0 -20
- data/examples/cucumber/features/support/env.rb +0 -13
- data/examples/cucumber/features/youtube.feature +0 -10
- data/examples/cucumber/features/youtube_steps.rb +0 -15
- data/examples/test_rspec.rb +0 -17
- data/examples/test_rspec1.rb +0 -36
- data/examples/test_unit.rb +0 -30
- data/lib/testingbot/capybara.rb +0 -66
- data/lib/testingbot/config.rb +0 -125
- data/lib/testingbot/cucumber.rb +0 -35
- data/lib/testingbot/hooks.rb +0 -287
- data/lib/testingbot/jasmine.rb +0 -29
- data/lib/testingbot/jasmine/README.rdoc +0 -16
- data/lib/testingbot/jasmine/Rakefile +0 -35
- data/lib/testingbot/jasmine/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/runner.rb +0 -4
- data/lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/jasmine/test/Rakefile +0 -9
- data/lib/testingbot/jasmine/test/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/test/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/test/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/test/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/selenium.rb +0 -127
- data/lib/testingbot/tunnel.rb +0 -104
- data/spec/integration/selenium1_spec.rb +0 -53
- data/spec/integration/selenium2_spec.rb +0 -60
- data/spec/integration/tunnel_spec.rb +0 -84
- data/spec/unit/api_spec.rb +0 -17
- data/spec/unit/config_spec.rb +0 -73
- data/spec/unit/tunnel_spec.rb +0 -41
- data/testingbot.gemspec +0 -25
- data/vendor/Testingbot-Tunnel.jar +0 -0
data/lib/testingbot/version.rb
CHANGED
@@ -4,23 +4,22 @@ require 'rspec'
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
5
5
|
|
6
6
|
describe "Testingbot Api" do
|
7
|
-
|
8
7
|
context "the API should return valid user information" do
|
9
8
|
it "should return info for the current user" do
|
10
|
-
@api = TestingBot::Api.new
|
9
|
+
@api = TestingBot::Api.new
|
11
10
|
@api.get_user_info.should_not be_empty
|
12
11
|
@api.get_user_info["first_name"].should_not be_empty
|
13
12
|
end
|
14
13
|
|
15
14
|
it "should raise an error when wrong credentials are provided" do
|
16
|
-
@api = TestingBot::Api.new(
|
17
|
-
lambda { @api.get_user_info }.should raise_error(
|
15
|
+
@api = TestingBot::Api.new("bogus", "false")
|
16
|
+
lambda { @api.get_user_info }.should raise_error(RestClient::Unauthorized)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
context "updating my user info via the API should work" do
|
22
21
|
it "should allow me to update my own user info" do
|
23
|
-
@api = TestingBot::Api.new
|
22
|
+
@api = TestingBot::Api.new
|
24
23
|
new_name = rand(36**9).to_s(36)
|
25
24
|
@api.update_user_info({ "first_name" => new_name }).should == true
|
26
25
|
@api.get_user_info["first_name"].should == new_name
|
@@ -29,60 +28,81 @@ describe "Testingbot Api" do
|
|
29
28
|
|
30
29
|
context "retrieve my own tests" do
|
31
30
|
it "should retrieve a list of my own tests" do
|
32
|
-
@api = TestingBot::Api.new
|
31
|
+
@api = TestingBot::Api.new
|
33
32
|
@api.get_tests.include?("data").should == true
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should provide info for a specific test" do
|
37
|
-
@api = TestingBot::Api.new
|
36
|
+
@api = TestingBot::Api.new
|
38
37
|
data = @api.get_tests["data"]
|
39
38
|
if data.length > 0
|
40
39
|
test_id = data.first["id"]
|
41
40
|
|
42
|
-
single_test = @api.
|
41
|
+
single_test = @api.get_test(test_id)
|
43
42
|
single_test["id"].should == test_id
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
46
|
it "should fail when trying to access a test that is not mine" do
|
48
|
-
@api = TestingBot::Api.new
|
49
|
-
lambda { @api.
|
47
|
+
@api = TestingBot::Api.new
|
48
|
+
lambda { @api.get_test(123423423423423) }.should raise_error(RestClient::NotFound)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
context "update a test" do
|
54
53
|
it "should update a test of mine" do
|
55
|
-
@api = TestingBot::Api.new
|
54
|
+
@api = TestingBot::Api.new
|
56
55
|
data = @api.get_tests["data"]
|
57
56
|
if data.length > 0
|
58
57
|
test_id = data.first["id"]
|
59
58
|
new_name = rand(36**9).to_s(36)
|
60
59
|
@api.update_test(test_id, { :name => new_name }).should == true
|
61
|
-
single_test = @api.
|
60
|
+
single_test = @api.get_test(test_id)
|
62
61
|
single_test["name"].should == new_name
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
it "should not update a test that is not mine" do
|
67
|
-
@api = TestingBot::Api.new
|
68
|
-
lambda { @api.update_test(123423423423423, { :name => "testingbot" }) }.should raise_error(
|
66
|
+
@api = TestingBot::Api.new
|
67
|
+
lambda { @api.update_test(123423423423423, { :name => "testingbot" }) }.should raise_error(RestClient::NotFound)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "fetch browsers" do
|
72
|
+
it "should fetch a list of browsers" do
|
73
|
+
@api = TestingBot::Api.new
|
74
|
+
@api.get_browsers.should_not be_empty
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
72
78
|
context "delete a test" do
|
73
79
|
it "should delete a test of mine" do
|
74
|
-
@api = TestingBot::Api.new
|
80
|
+
@api = TestingBot::Api.new
|
75
81
|
data = @api.get_tests["data"]
|
76
82
|
if data.length > 0
|
77
83
|
test_id = data.first["id"]
|
78
84
|
@api.delete_test(test_id).should == true
|
79
|
-
lambda { @api.
|
85
|
+
lambda { @api.get_test(test_id) }.should raise_error(RestClient::NotFound)
|
80
86
|
end
|
81
87
|
end
|
82
88
|
|
83
89
|
it "should not delete a test that is not mine" do
|
84
|
-
@api = TestingBot::Api.new
|
85
|
-
lambda { @api.delete_test(123423423423423) }.should raise_error(
|
90
|
+
@api = TestingBot::Api.new
|
91
|
+
lambda { @api.delete_test(123423423423423) }.should raise_error(RestClient::NotFound)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "TestingBot Storage" do
|
96
|
+
it "should upload a local file" do
|
97
|
+
@api = TestingBot::Api.new
|
98
|
+
response = @api.upload_local_file(File.join(File.dirname(__FILE__), "../resources/test.apk"))
|
99
|
+
response["app_url"].should include("tb://")
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should upload a remote file" do
|
103
|
+
@api = TestingBot::Api.new
|
104
|
+
response = @api.upload_remote_file("https://testingbot.com/appium/sample.apk")
|
105
|
+
response["app_url"].should include("tb://")
|
86
106
|
end
|
87
107
|
end
|
88
108
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ok
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/config.rb')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/tunnel.rb')
|
3
1
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot/api.rb')
|
4
|
-
require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot.rb')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/testingbot.rb')
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.syntax = :should
|
6
|
+
end
|
7
|
+
end
|
metadata
CHANGED
@@ -1,72 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testingbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jochen Delabie
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
17
|
-
none: false
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '2.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement:
|
28
|
-
none: false
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: selenium-webdriver
|
38
|
-
requirement: &70143118084900 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- -
|
38
|
+
- - ">="
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: '0'
|
44
|
-
type: :runtime
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *70143118084900
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rspec
|
49
|
-
requirement:
|
50
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
51
44
|
requirements:
|
52
|
-
- -
|
45
|
+
- - "~>"
|
53
46
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
47
|
+
version: '3.3'
|
55
48
|
type: :development
|
56
49
|
prerelease: false
|
57
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
58
55
|
- !ruby/object:Gem::Dependency
|
59
56
|
name: rake
|
60
|
-
requirement:
|
61
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
62
58
|
requirements:
|
63
|
-
- -
|
59
|
+
- - ">="
|
64
60
|
- !ruby/object:Gem::Version
|
65
61
|
version: '0'
|
66
62
|
type: :development
|
67
63
|
prerelease: false
|
68
|
-
version_requirements:
|
69
|
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: This gem makes interacting with the TestingBot API easy with Ruby
|
70
70
|
email:
|
71
71
|
- info@testingbot.com
|
72
72
|
executables:
|
@@ -74,88 +74,49 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .
|
78
|
-
- .
|
77
|
+
- ".github/workflows/test.yml"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE
|
81
|
-
- README.
|
82
|
+
- README.md
|
82
83
|
- Rakefile
|
83
84
|
- bin/testingbot
|
84
|
-
- examples/android.rb
|
85
|
-
- examples/capybara.rb
|
86
|
-
- examples/capybara_multiple_browsers.rb
|
87
|
-
- examples/cucumber/README.rdoc
|
88
|
-
- examples/cucumber/Rakefile
|
89
|
-
- examples/cucumber/features/support/env.rb
|
90
|
-
- examples/cucumber/features/youtube.feature
|
91
|
-
- examples/cucumber/features/youtube_steps.rb
|
92
|
-
- examples/test_rspec.rb
|
93
|
-
- examples/test_rspec1.rb
|
94
|
-
- examples/test_unit.rb
|
95
85
|
- lib/testingbot.rb
|
96
86
|
- lib/testingbot/api.rb
|
97
|
-
- lib/testingbot/capybara.rb
|
98
|
-
- lib/testingbot/config.rb
|
99
|
-
- lib/testingbot/cucumber.rb
|
100
|
-
- lib/testingbot/hooks.rb
|
101
|
-
- lib/testingbot/jasmine.rb
|
102
|
-
- lib/testingbot/jasmine/README.rdoc
|
103
|
-
- lib/testingbot/jasmine/Rakefile
|
104
|
-
- lib/testingbot/jasmine/public/javascripts/Player.js
|
105
|
-
- lib/testingbot/jasmine/public/javascripts/Song.js
|
106
|
-
- lib/testingbot/jasmine/runner.rb
|
107
|
-
- lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js
|
108
|
-
- lib/testingbot/jasmine/spec/javascripts/helpers/SpecHelper.js
|
109
|
-
- lib/testingbot/jasmine/spec/javascripts/support/jasmine.yml
|
110
|
-
- lib/testingbot/jasmine/test/Rakefile
|
111
|
-
- lib/testingbot/jasmine/test/public/javascripts/Player.js
|
112
|
-
- lib/testingbot/jasmine/test/public/javascripts/Song.js
|
113
|
-
- lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js
|
114
|
-
- lib/testingbot/jasmine/test/spec/javascripts/helpers/SpecHelper.js
|
115
|
-
- lib/testingbot/jasmine/test/spec/javascripts/support/jasmine.yml
|
116
|
-
- lib/testingbot/selenium.rb
|
117
|
-
- lib/testingbot/tunnel.rb
|
118
87
|
- lib/testingbot/version.rb
|
119
88
|
- spec/integration/api_spec.rb
|
120
|
-
- spec/
|
121
|
-
- spec/integration/selenium2_spec.rb
|
122
|
-
- spec/integration/tunnel_spec.rb
|
89
|
+
- spec/resources/test.apk
|
123
90
|
- spec/spec_helper.rb
|
124
|
-
|
125
|
-
|
126
|
-
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
91
|
+
homepage: https://testingbot.com
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
bug_tracker_uri: https://github.com/testingbot/testingbot_ruby/issues
|
96
|
+
documentation_uri: https://github.com/testingbot/testingbot_ruby
|
97
|
+
homepage_uri: https://github.com/testingbot/testingbot_ruby
|
98
|
+
source_code_uri: https://github.com/testingbot/testingbot_ruby
|
99
|
+
post_install_message:
|
132
100
|
rdoc_options: []
|
133
101
|
require_paths:
|
134
102
|
- lib
|
135
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
104
|
requirements:
|
138
|
-
- -
|
105
|
+
- - "~>"
|
139
106
|
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
107
|
+
version: '2.0'
|
141
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
109
|
requirements:
|
144
|
-
- -
|
110
|
+
- - ">="
|
145
111
|
- !ruby/object:Gem::Version
|
146
112
|
version: '0'
|
147
113
|
requirements: []
|
148
114
|
rubyforge_project: testingbot
|
149
|
-
rubygems_version:
|
150
|
-
signing_key:
|
151
|
-
specification_version:
|
152
|
-
summary: Ruby Gem to be used with testingbot.com
|
115
|
+
rubygems_version: 2.7.10
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Ruby API Gem to be used with testingbot.com
|
153
119
|
test_files:
|
154
120
|
- spec/integration/api_spec.rb
|
155
|
-
- spec/
|
156
|
-
- spec/integration/selenium2_spec.rb
|
157
|
-
- spec/integration/tunnel_spec.rb
|
121
|
+
- spec/resources/test.apk
|
158
122
|
- spec/spec_helper.rb
|
159
|
-
- spec/unit/api_spec.rb
|
160
|
-
- spec/unit/config_spec.rb
|
161
|
-
- spec/unit/tunnel_spec.rb
|
data/README.rdoc
DELETED
@@ -1,237 +0,0 @@
|
|
1
|
-
{<img src="https://secure.travis-ci.org/testingbot/testingbot_ruby.png" />}[http://travis-ci.org/testingbot/testingbot_ruby]
|
2
|
-
|
3
|
-
= TestingBot
|
4
|
-
|
5
|
-
Testingbot.com is a website where you can use our cloud based Selenium grid. Test your web applications in various environments/browsers/devices.
|
6
|
-
|
7
|
-
== How to install?
|
8
|
-
|
9
|
-
You can install our testingbot ruby-gem by running "gem install testingbot" on your commandline.
|
10
|
-
|
11
|
-
$ gem install testingbot
|
12
|
-
|
13
|
-
== Setup
|
14
|
-
|
15
|
-
After you installed the gem you need to run a one part setup.
|
16
|
-
Type testingbot in your commandline and fill in the API key and API secret you obtained on http://testingbot.com
|
17
|
-
$ testingbot
|
18
|
-
|
19
|
-
== Usage
|
20
|
-
|
21
|
-
=== Example Test::Unit
|
22
|
-
You can find an example in our examples folder, try something like this:
|
23
|
-
|
24
|
-
require "rubygems"
|
25
|
-
require "test/unit"
|
26
|
-
require "testingbot"
|
27
|
-
class ExampleTest < TestingBot::TestCase
|
28
|
-
attr_reader :browser
|
29
|
-
|
30
|
-
def setup
|
31
|
-
@browser = Selenium::Client::Driver.new \
|
32
|
-
:browser => "firefox",
|
33
|
-
:url => "http://www.google.com",
|
34
|
-
:platform => "WINDOWS",
|
35
|
-
:version => 10,
|
36
|
-
:timeout_in_second => 90
|
37
|
-
|
38
|
-
browser.start_new_browser_session
|
39
|
-
end
|
40
|
-
|
41
|
-
def teardown
|
42
|
-
browser.close_current_browser_session
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_page_search
|
46
|
-
browser.open "/"
|
47
|
-
assert_equal "Google", browser.title
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
=== Example RSpec 2
|
52
|
-
This example uses RSpec 2. You can run it with rspec test_rspec.rb
|
53
|
-
|
54
|
-
require 'rubygems'
|
55
|
-
require "selenium/client"
|
56
|
-
require 'rspec'
|
57
|
-
require 'testingbot'
|
58
|
-
require 'testingbot/tunnel'
|
59
|
-
|
60
|
-
# rspec 2
|
61
|
-
describe "People", :type => :selenium do
|
62
|
-
attr_reader :selenium_driver
|
63
|
-
before(:all) do
|
64
|
-
# uncomment if you want to use our Tunnel
|
65
|
-
# tunnel = TestingBot::Tunnel.new
|
66
|
-
# tunnel.start
|
67
|
-
|
68
|
-
@selenium_driver = Selenium::Client::Driver.new \
|
69
|
-
:browser => "firefox",
|
70
|
-
:url => "http://www.google.com",
|
71
|
-
:timeout_in_second => 60,
|
72
|
-
:platform => "WINDOWS",
|
73
|
-
:version => "10"
|
74
|
-
end
|
75
|
-
|
76
|
-
before(:each) do
|
77
|
-
@selenium_driver.start_new_browser_session
|
78
|
-
end
|
79
|
-
|
80
|
-
after(:each) do
|
81
|
-
@selenium_driver.close_current_browser_session
|
82
|
-
end
|
83
|
-
|
84
|
-
it "can find the right title" do
|
85
|
-
@selenium_driver.open "/"
|
86
|
-
@selenium_driver.title.should eql("Google")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
=== Example RSpec 1
|
91
|
-
This example uses RSpec 1. You can run it with spec test_rspec1.rb
|
92
|
-
|
93
|
-
require 'rubygems'
|
94
|
-
gem "rspec", "<2"
|
95
|
-
gem "selenium-client"
|
96
|
-
require "selenium/client"
|
97
|
-
require "selenium/rspec/spec_helper"
|
98
|
-
gem "testingbot"
|
99
|
-
require "testingbot"
|
100
|
-
|
101
|
-
describe "Test" do
|
102
|
-
attr_reader :selenium_driver
|
103
|
-
alias :page :selenium_driver
|
104
|
-
|
105
|
-
before(:all) do
|
106
|
-
@selenium_driver = Selenium::Client::Driver.new \
|
107
|
-
:browser => "firefox",
|
108
|
-
:url => "http://www.google.com",
|
109
|
-
:timeout_in_second => 90,
|
110
|
-
:platform => "WINDOWS",
|
111
|
-
:version => "10"
|
112
|
-
end
|
113
|
-
|
114
|
-
before(:each) do
|
115
|
-
@selenium_driver.start_new_browser_session
|
116
|
-
end
|
117
|
-
|
118
|
-
append_after(:each) do
|
119
|
-
@selenium_driver.close_current_browser_session
|
120
|
-
end
|
121
|
-
|
122
|
-
it "can find the right title" do
|
123
|
-
page.open "/"
|
124
|
-
page.title.should eql("Google")
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
=== Example RSpec 2 and Capybara
|
129
|
-
This example uses RSpec 2 together with capybara and Selenium webdriver. You can run it with rspec capybara.rb
|
130
|
-
|
131
|
-
require 'rspec'
|
132
|
-
require 'capybara/rspec'
|
133
|
-
require 'testingbot'
|
134
|
-
require 'testingbot/capybara'
|
135
|
-
|
136
|
-
TestingBot::config do |config|
|
137
|
-
config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
|
138
|
-
# config.require_tunnel # uncomment if you want to use our Tunnel
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "People", :type => :request do
|
142
|
-
before :each do
|
143
|
-
Capybara.current_driver = :testingbot
|
144
|
-
Capybara.app_host = "http://testingbot.com"
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'has a homepage with the word Selenium' do
|
148
|
-
visit '/'
|
149
|
-
page.should have_content('Selenium')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
=== Example RSpec 2, Capybara and Rails
|
154
|
-
In this example we will need rspec-rails and Capybara, a rack server will be started by Capybara to run your localhost tests.
|
155
|
-
Add the example below in spec/integration/home_spec.rb
|
156
|
-
----------------------------------------------------------
|
157
|
-
spec_helper.rb:
|
158
|
-
|
159
|
-
require 'capybara/rspec'
|
160
|
-
require 'capybara/rails'
|
161
|
-
require 'testingbot'
|
162
|
-
require 'testingbot/capybara'
|
163
|
-
|
164
|
-
----------------------------------------------------------
|
165
|
-
spec/integration/home_spec.rb:
|
166
|
-
|
167
|
-
require 'spec_helper'
|
168
|
-
|
169
|
-
TestingBot::config do |config|
|
170
|
-
config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS", :localhost => "YES" }
|
171
|
-
config.require_tunnel
|
172
|
-
end
|
173
|
-
|
174
|
-
describe 'home page' do
|
175
|
-
before :each do
|
176
|
-
Capybara.server_port = 3011
|
177
|
-
Capybara.current_driver = :testingbot
|
178
|
-
Capybara.app_host = "http://127.0.0.1:3011"
|
179
|
-
end
|
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
|
-
|
187
|
-
it "shows the home page", :type => :request do
|
188
|
-
visit '/'
|
189
|
-
page.should have_content('Selenium')
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
=== Example RSpec 2 run on multiple browsers
|
194
|
-
Use the :multibrowser => true statement to indicate you want to test on multiple browsers.
|
195
|
-
This should work together with Capybara as well.
|
196
|
-
|
197
|
-
require 'rubygems'
|
198
|
-
require "selenium/client"
|
199
|
-
require 'rspec'
|
200
|
-
require 'testingbot'
|
201
|
-
require 'testingbot/tunnel'
|
202
|
-
|
203
|
-
TestingBot::config do |config|
|
204
|
-
config[:desired_capabilities] = [{ :browserName => "firefox", :version => 9, :platform => "WINDOWS" }, { :browserName => "firefox", :version => 11, :platform => "WINDOWS" }]
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "Google", :type => :selenium, :multibrowser => true do
|
208
|
-
it "can find the right title" do
|
209
|
-
page.navigate.to "http://www.google.com"
|
210
|
-
page.title.should eql("Google")
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
== Capybara and Cucumber
|
215
|
-
The examples directory contains an example of testing with Capybara and Cucumber.
|
216
|
-
The Rakefile in examples/cucumber contains a cucumber task which will run the same Cucumber story on multiple browsers.
|
217
|
-
|
218
|
-
More info available on http://testingbot.com/support/getting-started/cucumber.html
|
219
|
-
|
220
|
-
== Test this gem
|
221
|
-
The tests for this gem are located in the spec folder, you can run them with this Rake task:
|
222
|
-
rake spec
|
223
|
-
|
224
|
-
== Extra options
|
225
|
-
You can specify extra options like enabling/disabling the screenrecording or screenshot feature.
|
226
|
-
For WebDriver use the config[:desired_capabilities] to specify extra options.
|
227
|
-
|
228
|
-
For RC tests use the start_new_browser_session(options) options hash.
|
229
|
-
|
230
|
-
== More information
|
231
|
-
|
232
|
-
Get more information on http://testingbot.com
|
233
|
-
|
234
|
-
== Copyright
|
235
|
-
|
236
|
-
Copyright (c) TestingBot
|
237
|
-
Please see our LICENSE
|