Navigation Menu

Skip to content

Commit

Permalink
spec: cleanup the runner a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Jan 27, 2014
1 parent 3db900f commit cdfb2b0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions spec/runner.rb
Expand Up @@ -3,8 +3,9 @@
require 'rest_client'
require 'json'

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

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

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

if state["parallel_sessions_running"] < state["parallel_sessions_max_allowed"]
Expand All @@ -29,16 +30,21 @@
sleep 30
end

browser = Selenium::WebDriver.for(:remote, url: url, desired_capabilities: cap)
browser = Selenium::WebDriver.for(:remote, url: hub, desired_capabilities: cap)
browser.navigate.to('http://localhost:9292')
rescue Exception
retry
end

unless (browser.find_element(:css, '.rspec-report') rescue false)
puts "\rThe specs didn't load."
begin
browser.find_element(:css, '.rspec-report')
rescue Selenium::WebDriver::Error::NoSuchElementError
puts "\rThe specs failed loading."
browser.quit
exit 1
rescue Exception
browser.quit
raise
end

print "\rRunning specs..."
Expand Down

0 comments on commit cdfb2b0

Please sign in to comment.