Skip to content

Commit 930f9cb

Browse files
kamal-kaur04francisf
authored andcommitted
migrate master branch scripts to Sel 4
1 parent 84d9f13 commit 930f9cb

File tree

6 files changed

+67
-33
lines changed

6 files changed

+67
-33
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<dependency>
3535
<groupId>org.seleniumhq.selenium</groupId>
3636
<artifactId>selenium-java</artifactId>
37-
<version>3.12.0</version>
37+
<version>4.1.0</version>
3838
</dependency>
3939
<dependency>
4040
<groupId>com.browserstack</groupId>

src/test/java/com/browserstack/BrowserStackTestNGTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ public void setUp(String config_file, String environment) throws Exception {
3434
Iterator it = envCapabilities.entrySet().iterator();
3535
while (it.hasNext()) {
3636
Map.Entry pair = (Map.Entry) it.next();
37-
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
37+
capabilities.setCapability(pair.getKey().toString(), pair.getValue());
3838
}
3939

4040
Map<String, String> commonCapabilities = (Map<String, String>) config.get("capabilities");
4141
it = commonCapabilities.entrySet().iterator();
4242
while (it.hasNext()) {
4343
Map.Entry pair = (Map.Entry) it.next();
4444
if (capabilities.getCapability(pair.getKey().toString()) == null) {
45-
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
45+
capabilities.setCapability(pair.getKey().toString(), pair.getValue());
46+
} else if (pair.getKey().toString().equalsIgnoreCase("bstack:options")) {
47+
HashMap bstackOptionsMap = (HashMap) pair.getValue();
48+
bstackOptionsMap.putAll((HashMap) capabilities.getCapability("bstack:options"));
49+
capabilities.setCapability(pair.getKey().toString(), bstackOptionsMap);
4650
}
4751
}
4852

@@ -56,12 +60,14 @@ public void setUp(String config_file, String environment) throws Exception {
5660
accessKey = (String) config.get("key");
5761
}
5862

59-
if (capabilities.getCapability("browserstack.local") != null
60-
&& capabilities.getCapability("browserstack.local") == "true") {
61-
l = new Local();
62-
Map<String, String> options = new HashMap<String, String>();
63-
options.put("key", accessKey);
64-
l.start(options);
63+
if (capabilities.getCapability("bstack:options") != null) {
64+
HashMap bstackOptionsMap = (HashMap) capabilities.getCapability("bstack:options");
65+
if (bstackOptionsMap.get("local").toString().equalsIgnoreCase("true")) {
66+
l = new Local();
67+
Map<String, String> options = new HashMap<String, String>();
68+
options.put("key", accessKey);
69+
l.start(options);
70+
}
6571
}
6672

6773
driver = new RemoteWebDriver(

src/test/resources/conf/local.conf.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"key": "BROWSERSTACK_ACCESS_KEY",
55

66
"capabilities": {
7-
"build": "browserstack-build-1",
8-
"name": "local_test",
9-
"browserstack.debug": true,
10-
"browserstack.local": true
7+
"bstack:options": {
8+
"buildName": "browserstack-build-1",
9+
"sessionName": "local_test",
10+
"debug": true,
11+
"local": true
12+
}
1113
},
1214

1315
"environments": {
1416
"chrome": {
15-
"browser": "chrome"
17+
"bstack:options": {
18+
"browserName": "chrome"
19+
}
1620
}
1721
}
1822
}

src/test/resources/conf/parallel.conf.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@
44
"key": "BROWSERSTACK_ACCESS_KEY",
55

66
"capabilities": {
7-
"build": "browserstack-build-1",
8-
"name": "parallel_test",
9-
"browserstack.debug": true
7+
"bstack:options": {
8+
"buildName": "browserstack-build-1",
9+
"sessionName": "parallel_test",
10+
"browserVersion": "latest",
11+
"debug": true
12+
}
1013
},
1114

1215
"environments": {
1316
"env1": {
14-
"browser": "chrome"
17+
"bstack:options": {
18+
"browserName": "chrome"
19+
}
1520
},
1621
"env2": {
17-
"browser": "firefox"
22+
"bstack:options": {
23+
"browserName": "firefox"
24+
}
1825
},
1926
"env3": {
20-
"os": "OS X",
21-
"browser": "safari"
27+
"bstack:options": {
28+
"os": "OS X",
29+
"browserName": "safari"
30+
}
2231
}
2332
}
2433
}

src/test/resources/conf/single.conf.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
"key": "BROWSERSTACK_ACCESS_KEY",
55

66
"capabilities": {
7-
"build": "browserstack-build-1",
8-
"name": "single_test",
9-
"browserstack.debug": true
7+
"bstack:options": {
8+
"buildName": "browserstack-build-1",
9+
"sessionName": "single_test",
10+
"browserVersion": "latest",
11+
"debug": true
12+
}
1013
},
1114

1215
"environments": {
1316
"chrome": {
14-
"browser": "chrome"
17+
"bstack:options": {
18+
"browserName": "chrome"
19+
}
1520
}
1621
}
1722
}

src/test/resources/conf/suite.conf.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44
"key": "BROWSERSTACK_ACCESS_KEY",
55

66
"capabilities": {
7-
"build": "browserstack-build-1",
8-
"name": "suite_test",
9-
"browserstack.debug": true
7+
"bstack:options": {
8+
"buildName": "browserstack-build-1",
9+
"sessionName": "suite_test",
10+
"debug": true
11+
}
1012
},
1113

1214
"environments": {
1315
"chrome": {
14-
"browser": "chrome"
16+
"bstack:options": {
17+
"browserName": "chrome"
18+
}
1519
},
1620
"firefox": {
17-
"browser": "firefox"
21+
"bstack:options": {
22+
"browserName": "firefox"
23+
}
1824
},
1925
"safari": {
20-
"os": "OS X",
21-
"browser": "safari"
26+
"bstack:options": {
27+
"os": "OS X",
28+
"browserName": "safari"
29+
}
2230
},
2331
"ie": {
24-
"browser": "internet explorer"
32+
"bstack:options": {
33+
"browserName": "internet explorer"
34+
}
2535
}
2636
}
2737
}

0 commit comments

Comments
 (0)