Skip to content

Commit 10fb326

Browse files
authored
Merge pull request #13 from Varun-garg/java10andSelenium3
java 10 and selenium 3
2 parents 8e008b9 + 7017dcc commit 10fb326

File tree

4 files changed

+54
-62
lines changed

4 files changed

+54
-62
lines changed

pom.xml

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>com.browserstack</groupId>
@@ -12,47 +12,44 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
<maven.compiler.source>1.6</maven.compiler.source>
16+
<maven.compiler.target>1.6</maven.compiler.target>
1517
<surefire.version>2.19.1</surefire.version>
1618

1719
<test.file></test.file>
1820
<config.file>default</config.file>
1921
</properties>
2022

2123
<dependencies>
22-
<dependency>
23-
<groupId>org.testng</groupId>
24-
<artifactId>testng</artifactId>
25-
<version>6.9.10</version>
26-
</dependency>
27-
<dependency>
28-
<groupId>commons-io</groupId>
29-
<artifactId>commons-io</artifactId>
30-
<version>1.3.2</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.seleniumhq.selenium</groupId>
34-
<artifactId>selenium-java</artifactId>
35-
<version>2.52.0</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>com.browserstack</groupId>
39-
<artifactId>browserstack-local-java</artifactId>
40-
<version>0.1.0</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>com.googlecode.json-simple</groupId>
44-
<artifactId>json-simple</artifactId>
45-
<version>1.1.1</version>
46-
</dependency>
24+
<dependency>
25+
<groupId>org.testng</groupId>
26+
<artifactId>testng</artifactId>
27+
<version>6.9.10</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>commons-io</groupId>
31+
<artifactId>commons-io</artifactId>
32+
<version>1.3.2</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.seleniumhq.selenium</groupId>
36+
<artifactId>selenium-java</artifactId>
37+
<version>3.12.0</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.browserstack</groupId>
41+
<artifactId>browserstack-local-java</artifactId>
42+
<version>0.1.0</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>com.googlecode.json-simple</groupId>
46+
<artifactId>json-simple</artifactId>
47+
<version>1.1.1</version>
48+
</dependency>
4749
</dependencies>
4850

4951
<build>
5052
<plugins>
51-
<plugin>
52-
<groupId>org.apache.maven.plugins</groupId>
53-
<artifactId>maven-surefire-plugin</artifactId>
54-
<version>2.12.4</version>
55-
</plugin>
5653
<plugin>
5754
<groupId>org.apache.maven.plugins</groupId>
5855
<artifactId>maven-surefire-plugin</artifactId>
Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
package com.browserstack;
2-
import com.browserstack.local.Local;
32

4-
import java.io.File;
53
import java.io.FileReader;
6-
import java.io.IOException;
7-
import java.io.InputStream;
84
import java.net.URL;
95
import java.util.HashMap;
10-
import java.util.Map;
11-
import java.util.ArrayList;
12-
import java.util.List;
136
import java.util.Iterator;
7+
import java.util.Map;
8+
9+
import com.browserstack.local.Local;
10+
1411
import org.json.simple.JSONObject;
15-
import org.json.simple.JSONArray;
1612
import org.json.simple.parser.JSONParser;
17-
1813
import org.openqa.selenium.WebDriver;
19-
import org.openqa.selenium.remote.RemoteWebDriver;
2014
import org.openqa.selenium.remote.DesiredCapabilities;
21-
22-
import org.testng.annotations.BeforeMethod;
15+
import org.openqa.selenium.remote.RemoteWebDriver;
2316
import org.testng.annotations.AfterMethod;
24-
import org.testng.annotations.Test;
25-
import org.testng.annotations.Parameters;
26-
import org.testng.annotations.DataProvider;
27-
import org.testng.annotations.Factory;
28-
import org.testng.Assert;
29-
17+
import org.testng.annotations.BeforeMethod;
3018

3119
public class BrowserStackTestNGTest {
3220
public WebDriver driver;
3321
private Local l;
3422

35-
@BeforeMethod(alwaysRun=true)
36-
@org.testng.annotations.Parameters(value={"config", "environment"})
23+
@BeforeMethod(alwaysRun = true)
24+
@org.testng.annotations.Parameters(value = { "config", "environment" })
25+
@SuppressWarnings("unchecked")
3726
public void setUp(String config_file, String environment) throws Exception {
3827
JSONParser parser = new JSONParser();
3928
JSONObject config = (JSONObject) parser.parse(new FileReader("src/test/resources/conf/" + config_file));
@@ -44,42 +33,46 @@ public void setUp(String config_file, String environment) throws Exception {
4433
Map<String, String> envCapabilities = (Map<String, String>) envs.get(environment);
4534
Iterator it = envCapabilities.entrySet().iterator();
4635
while (it.hasNext()) {
47-
Map.Entry pair = (Map.Entry)it.next();
36+
Map.Entry pair = (Map.Entry) it.next();
4837
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
4938
}
50-
39+
5140
Map<String, String> commonCapabilities = (Map<String, String>) config.get("capabilities");
5241
it = commonCapabilities.entrySet().iterator();
5342
while (it.hasNext()) {
54-
Map.Entry pair = (Map.Entry)it.next();
55-
if(capabilities.getCapability(pair.getKey().toString()) == null){
43+
Map.Entry pair = (Map.Entry) it.next();
44+
if (capabilities.getCapability(pair.getKey().toString()) == null) {
5645
capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
5746
}
5847
}
5948

6049
String username = System.getenv("BROWSERSTACK_USERNAME");
61-
if(username == null) {
50+
if (username == null) {
6251
username = (String) config.get("user");
6352
}
6453

6554
String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
66-
if(accessKey == null) {
55+
if (accessKey == null) {
6756
accessKey = (String) config.get("key");
6857
}
6958

70-
if(capabilities.getCapability("browserstack.local") != null && capabilities.getCapability("browserstack.local") == "true"){
59+
if (capabilities.getCapability("browserstack.local") != null
60+
&& capabilities.getCapability("browserstack.local") == "true") {
7161
l = new Local();
7262
Map<String, String> options = new HashMap<String, String>();
7363
options.put("key", accessKey);
7464
l.start(options);
7565
}
7666

77-
driver = new RemoteWebDriver(new URL("http://"+username+":"+accessKey+"@"+config.get("server")+"/wd/hub"), capabilities);
67+
driver = new RemoteWebDriver(
68+
new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
7869
}
7970

80-
@AfterMethod(alwaysRun=true)
71+
@AfterMethod(alwaysRun = true)
8172
public void tearDown() throws Exception {
8273
driver.quit();
83-
if(l != null) l.stop();
74+
if (l != null) {
75+
l.stop();
76+
}
8477
}
8578
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"browser": "firefox"
1818
},
1919
"safari": {
20+
"os": "OS X",
2021
"browser": "safari"
2122
},
2223
"ie": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"browser": "firefox"
1818
},
1919
"safari": {
20+
"os": "OS X",
2021
"browser": "safari"
2122
},
2223
"ie": {

0 commit comments

Comments
 (0)