Skip to content

Commit b54dd40

Browse files
committed
browserstack rspec integration
0 parents  commit b54dd40

7 files changed

Lines changed: 105 additions & 0 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# A sample Gemfile
2+
source "https://rubygems.org"
3+
4+
# gem "rails"
5+
6+
7+
gem "selenium-webdriver"
8+
gem "rspec"
9+
gem "parallel_tests"

Gemfile.lock

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
childprocess (0.5.7)
5+
ffi (~> 1.0, >= 1.0.11)
6+
diff-lcs (1.2.5)
7+
ffi (1.9.10)
8+
multi_json (1.11.2)
9+
parallel (0.9.1)
10+
parallel_tests (0.16.5)
11+
parallel
12+
rspec (3.4.0)
13+
rspec-core (~> 3.4.0)
14+
rspec-expectations (~> 3.4.0)
15+
rspec-mocks (~> 3.4.0)
16+
rspec-core (3.4.3)
17+
rspec-support (~> 3.4.0)
18+
rspec-expectations (3.4.0)
19+
diff-lcs (>= 1.2.0, < 2.0)
20+
rspec-support (~> 3.4.0)
21+
rspec-mocks (3.4.1)
22+
diff-lcs (>= 1.2.0, < 2.0)
23+
rspec-support (~> 3.4.0)
24+
rspec-support (3.4.1)
25+
rubyzip (1.1.7)
26+
selenium-webdriver (2.48.1)
27+
childprocess (~> 0.5)
28+
multi_json (~> 1.0)
29+
rubyzip (~> 1.0)
30+
websocket (~> 1.0)
31+
websocket (1.2.2)
32+
33+
PLATFORMS
34+
ruby
35+
36+
DEPENDENCIES
37+
parallel_tests
38+
rspec
39+
selenium-webdriver
40+
41+
BUNDLED WITH
42+
1.10.6

spec/.DS_Store

6 KB
Binary file not shown.

spec/browserstack_driver.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'selenium-webdriver'
2+
3+
module BrowserStackDriver
4+
USERNAME = ENV['BROWSERSTACK_USERNAME']
5+
BROWSERSTACK_ACCESS_KEY = ENV['BROWSERSTACK_KEY']
6+
7+
class << self
8+
def browserstack_endpoint
9+
url = "http://#{USERNAME}:#{BROWSERSTACK_ACCESS_KEY}@hub.browserstack.com/wd/hub"
10+
end
11+
12+
def caps
13+
caps = {
14+
"browser": "firefox",
15+
"browser_version": "16.0",
16+
"os": "Windows",
17+
"os_version": "7"
18+
}
19+
end
20+
21+
def new_driver
22+
Selenium::WebDriver.for :remote, :url => browserstack_endpoint, :desired_capabilities => caps
23+
end
24+
end
25+
end

spec/google_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require_relative './spec_helper.rb'
2+
3+
describe "Google's Search Functionality" do
4+
it "can find search results", :run_on_browserstack => true do
5+
@driver.manage.timeouts.implicit_wait = 10
6+
@driver.navigate.to "http://www.google.com"
7+
8+
raise "Unable to load Google." unless @driver.title.include? "Google"
9+
10+
query = @driver.find_element :name, "q"
11+
query.send_keys "BrowserStack"
12+
query.submit
13+
14+
puts @driver.title
15+
end
16+
end

spec/spec_helper.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'rspec'
2+
require_relative './browserstack_driver.rb'
3+
4+
RSpec.configure do |config|
5+
config.around(:example, :run_on_browserstack => true) do |example|
6+
@driver = BrowserStackDriver.new_driver
7+
begin
8+
example.run
9+
ensure
10+
@driver.quit
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)