Skip to content

Commit 4297b48

Browse files
committed
Merge branch 'sdk' of github.com:kamal-kaur04/testng-browserstack into merge-sdk-branch-in-master
2 parents a0fb4ed + 09a0d92 commit 4297b48

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ local.log
66
.gradle
77
build/
88
.DS_Store
9-
browserstack.err
109
gradle
1110
gradlew
1211
gradlew.bat
1312
logs
14-
.classpath
15-
.project
16-
.settings
17-
test-output
13+
browserstack.err

browserstack.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# =============================
44
# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
55
# BROWSERSTACK_ACCESS_KEY as env variables
6-
userName: BROWSERSTACK_USERNAME
7-
accessKey: BROWSERSTACK_ACCESS_KEY
6+
userName: YOUR_USERNAME
7+
accessKey: YOUR_ACCESS_KEY
88

99
# ======================
1010
# Organizing your tests
@@ -19,6 +19,8 @@ accessKey: BROWSERSTACK_ACCESS_KEY
1919
buildName: browserstack-build-1
2020
# Use `projectName` to set the name of your project. Example, Marketing Website
2121
projectName: BrowserStack Samples
22+
# Use `framework` to set the framework of your project. Example, testng, cucumber, cucumber-testng
23+
framework: testng
2224

2325
# =======================================
2426
# Platforms (Browsers / Devices to test)
@@ -56,9 +58,9 @@ parallelsPerPlatform: 1
5658
# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
5759
# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
5860
browserstackLocal: true # <boolean> (Default false)
59-
#browserStackLocalOptions:
60-
# Options to be passed to BrowserStack local in-case of advanced configurations
61-
# localIdentifier: abcd # <string> (Default: null) Needed if you need to run multiple instances of local.
61+
#browserStackLocalOptions:
62+
# Options to be passed to BrowserStack local in-case of advanced configurations
63+
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
6264
# forceLocal: true # <boolean> (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
6365
# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
6466

src/test/java/com/browserstack/BStackDemoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.browserstack;
22

3-
import com.browserstack.BrowserStackRemoteTest;
3+
import com.browserstack.SeleniumTest;
44
import org.openqa.selenium.By;
55
import org.testng.Assert;
66
import org.testng.annotations.Test;
77

8-
public class BStackDemoTest extends BrowserStackRemoteTest {
8+
public class BStackDemoTest extends SeleniumTest {
99
@Test
1010
public void addProductToCart() throws Exception {
1111
// navigate to bstackdemo

src/test/java/com/browserstack/LocalTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import org.testng.Assert;
44
import org.testng.annotations.Test;
55

6-
public class LocalTest extends BrowserStackRemoteTest {
6+
public class LocalTest extends SeleniumTest {
77

88
@Test
99
public void test() throws Exception {
10-
driver.get("http://bs-local.com:45691/check");
10+
driver.get("http://bs-local.com:45454/");
1111

12-
Assert.assertTrue(driver.getPageSource().contains("Up and running"));
12+
Assert.assertTrue(driver.getTitle().contains("BrowserStack Local"));
1313
}
1414
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.browserstack;
2+
3+
import java.net.URL;
4+
import java.util.HashMap;
5+
6+
import org.testng.annotations.AfterMethod;
7+
import org.testng.annotations.BeforeMethod;
8+
import org.openqa.selenium.WebDriver;
9+
import org.openqa.selenium.chrome.ChromeDriver;
10+
import org.openqa.selenium.chrome.ChromeOptions;
11+
12+
public class SeleniumTest {
13+
public WebDriver driver;
14+
15+
@BeforeMethod(alwaysRun = true)
16+
@SuppressWarnings("unchecked")
17+
public void setUp() throws Exception {
18+
ChromeOptions options = new ChromeOptions();
19+
options.addArguments("start-maximized");
20+
driver = new ChromeDriver(options);
21+
}
22+
23+
@AfterMethod(alwaysRun = true)
24+
public void tearDown() throws Exception {
25+
driver.quit();
26+
}
27+
}

0 commit comments

Comments
 (0)