File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 3
3
require 'rest_client'
4
4
require 'json'
5
5
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
8
9
9
10
cap [ 'platform' ] = ENV [ 'SELENIUM_PLATFORM' ] || 'ANY'
10
11
cap [ 'browser' ] = ENV [ 'SELENIUM_BROWSER' ] || 'chrome'
18
19
19
20
begin
20
21
loop do
21
- response = RestClient . get ( "https:// #{ ENV [ 'BS_USERNAME' ] } : #{ ENV [ 'BS_AUTHKEY' ] } @www.browserstack.com/automate/ plan.json" )
22
+ response = RestClient . get ( plan )
22
23
state = JSON . parse ( response . to_str )
23
24
24
25
if state [ "parallel_sessions_running" ] < state [ "parallel_sessions_max_allowed" ]
29
30
sleep 30
30
31
end
31
32
32
- browser = Selenium ::WebDriver . for ( :remote , url : url , desired_capabilities : cap )
33
+ browser = Selenium ::WebDriver . for ( :remote , url : hub , desired_capabilities : cap )
33
34
browser . navigate . to ( 'http://localhost:9292' )
34
35
rescue Exception
35
36
retry
36
37
end
37
38
38
- unless ( browser . find_element ( :css , '.rspec-report' ) rescue false )
39
- puts "\r The specs didn't load."
39
+ begin
40
+ browser . find_element ( :css , '.rspec-report' )
41
+ rescue Selenium ::WebDriver ::Error ::NoSuchElementError
42
+ puts "\r The specs failed loading."
40
43
browser . quit
41
44
exit 1
45
+ rescue Exception
46
+ browser . quit
47
+ raise
42
48
end
43
49
44
50
print "\r Running specs..."
You can’t perform that action at this time.
0 commit comments