Skip to content

Commit 32b2179

Browse files
authored
Merge branch 'master' into migrate-sample-tests-to-bstackdemo
2 parents 12265bb + f2a12b3 commit 32b2179

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# gauge-browserstack
1+
# gauge-java-browserstack
22

33
[Gauge](https://docs.gauge.org/) Integration with BrowserStack
44

@@ -28,4 +28,4 @@
2828
* [Documentation for writing Automate test scripts in Java](https://www.browserstack.com/automate/java)
2929
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
3030
* [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate)
31-
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)
31+
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
11
package com.browserstack.gauge.pages;
22

33
public class DriverFactory {
4+
private static final String USERNAME = System.getenv("BROWSERSTACK_USERNAME");
5+
private static final String AUTOMATE_KEY = System.getenv("BROWSERSTACK_ACCESS_KEY");
6+
private static final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";
7+
8+
private static WebDriver driver;
9+
10+
public static WebDriver getDriver() {
11+
return driver;
12+
}
13+
14+
@BeforeSpec
15+
public void setUp() {
16+
try {
17+
DesiredCapabilities caps = new DesiredCapabilities();
18+
19+
// Capabilities from environment
20+
if(System.getenv("DEVICE") != null){
21+
caps.setCapability("browserName", System.getenv("BROWSERNAME"));
22+
caps.setCapability("platform", System.getenv("PLATFORM"));
23+
caps.setCapability("device", System.getenv("DEVICE"));
24+
}
25+
else {
26+
caps.setCapability("browser", System.getenv("BROWSER"));
27+
caps.setCapability("browser_version", System.getenv("BROWSER_VERSION"));
28+
29+
caps.setCapability("os", System.getenv("OS"));
30+
caps.setCapability("os_version", System.getenv("OS_VERSION"));
31+
}
32+
33+
// Hardcoded capabilities
34+
caps.setCapability("build", "browserstack-build-1");
35+
caps.setCapability("browserstack.debug", "true");
36+
caps.setCapability("browserstack.source", "gauge-java:sample-master:v1.0");
37+
caps.setCapability("name", "BStack gauge-java");
38+
39+
URL remoteURL = new URL(URL);
40+
41+
driver = new RemoteWebDriver(remoteURL, caps);
42+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
43+
44+
} catch (MalformedURLException e) {
45+
46+
System.out.println(e.toString());
47+
48+
}
49+
}
50+
51+
@AfterSpec
52+
public void tearDown() {
53+
driver.close();
54+
driver.quit();
55+
}
456
}

0 commit comments

Comments
 (0)