@@ -20,14 +20,19 @@ public class SearchSpec {
2020 private static final String AUTOMATE_KEY = System .getenv ("BROWSERSTACK_ACCESS_KEY" );
2121 private static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub.browserstack.com/wd/hub" ;
2222 private WebDriver driver ;
23- private Local local ;
23+ private static Local local ;
24+
2425 @ BeforeSuite
2526 public void beforeSuite () throws Exception {
26- if (!(System .getenv ("LOCAL" ).isEmpty ()) && System .getenv ("LOCAL" ).equalsIgnoreCase ("true" )) {
27- local = new Local ();
28- Map <String , String > options = new HashMap <String , String >();
29- options .put ("key" , AUTOMATE_KEY );
30- local .start (options );
27+ try {
28+ if (!(System .getenv ("LOCAL" ).isEmpty ()) && System .getenv ("LOCAL" ).equalsIgnoreCase ("true" )) {
29+ local = new Local ();
30+ Map <String , String > options = new HashMap <String , String >();
31+ options .put ("key" , AUTOMATE_KEY );
32+ local .start (options );
33+ }
34+ } catch (Exception e ) {
35+ System .out .println ("Error while start local - " + e );
3136 }
3237 }
3338 @ BeforeSpec
@@ -37,19 +42,15 @@ public void setUp() throws Exception {
3742 HashMap <String , Object > browserstackOptions = new HashMap <String , Object >();
3843
3944 if (!(System .getenv ("LOCAL" ).isEmpty ()) && System .getenv ("LOCAL" ).equalsIgnoreCase ("true" )) {
40- if (local == null || !local .isRunning ()){
41- local = new Local ();
42- Map <String , String > options = new HashMap <String , String >();
43- options .put ("key" , AUTOMATE_KEY );
44- local .start (options );
45+ if (local != null && local .isRunning ()) {
46+ browserstackOptions .put ("local" , "true" );
4547 }
46- browserstackOptions .put ("local" , "true" );
4748 }
4849
4950 // Capabilities from environment
5051 if (System .getenv ("DEVICE" ) != null ){
5152 caps .setCapability ("browserName" , System .getenv ("BROWSERNAME" ));
52- caps .setCapability ("platform " , System .getenv ("PLATFORM" ));
53+ caps .setCapability ("os " , System .getenv ("PLATFORM" ));
5354 caps .setCapability ("deviceName" , System .getenv ("DEVICE" ));
5455 }
5556 else {
@@ -61,6 +62,7 @@ public void setUp() throws Exception {
6162 }
6263 browserstackOptions .put ("buildName" , "browserstack-build-1" );
6364 browserstackOptions .put ("sessionName" , "BStack Sample Gauge" );
65+ browserstackOptions .put ("source" , "gauge:sample-master:v1.0" );
6466 caps .setCapability ("bstack:options" , browserstackOptions );
6567
6668 java .net .URL remoteURL = new URL (URL );
0 commit comments