Skip to content

Commit cdfb2b0

Browse files
committedJan 27, 2014
spec: cleanup the runner a bit
1 parent 3db900f commit cdfb2b0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎spec/runner.rb

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
require 'rest_client'
44
require 'json'
55

6-
url = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@hub.browserstack.com/wd/hub"
7-
cap = Selenium::WebDriver::Remote::Capabilities.new
6+
hub = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@hub.browserstack.com/wd/hub"
7+
plan = "https://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@www.browserstack.com/automate/plan.json"
8+
cap = Selenium::WebDriver::Remote::Capabilities.new
89

910
cap['platform'] = ENV['SELENIUM_PLATFORM'] || 'ANY'
1011
cap['browser'] = ENV['SELENIUM_BROWSER'] || 'chrome'
@@ -18,7 +19,7 @@
1819

1920
begin
2021
loop do
21-
response = RestClient.get("https://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@www.browserstack.com/automate/plan.json")
22+
response = RestClient.get(plan)
2223
state = JSON.parse(response.to_str)
2324

2425
if state["parallel_sessions_running"] < state["parallel_sessions_max_allowed"]
@@ -29,16 +30,21 @@
2930
sleep 30
3031
end
3132

32-
browser = Selenium::WebDriver.for(:remote, url: url, desired_capabilities: cap)
33+
browser = Selenium::WebDriver.for(:remote, url: hub, desired_capabilities: cap)
3334
browser.navigate.to('http://localhost:9292')
3435
rescue Exception
3536
retry
3637
end
3738

38-
unless (browser.find_element(:css, '.rspec-report') rescue false)
39-
puts "\rThe specs didn't load."
39+
begin
40+
browser.find_element(:css, '.rspec-report')
41+
rescue Selenium::WebDriver::Error::NoSuchElementError
42+
puts "\rThe specs failed loading."
4043
browser.quit
4144
exit 1
45+
rescue Exception
46+
browser.quit
47+
raise
4248
end
4349

4450
print "\rRunning specs..."

0 commit comments

Comments
 (0)
Please sign in to comment.