Skip to content

Commit 787655c

Browse files
committed
fixing tests and creating testng XML files to run tests off of
1 parent 6970cea commit 787655c

File tree

13 files changed

+134
-91
lines changed

13 files changed

+134
-91
lines changed

.idea/runConfigurations/Run_Mac_Tests.xml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Run_Nunit_SampleTest_.xml renamed to .idea/runConfigurations/Run_Mac_Tests2.xml

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Run_Windows_Tests.xml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ addons:
88

99
script:
1010
- ./mac_install_browsers.sh
11-
- mvn clean test -Dgroups=mac
11+
- mvn clean test -Dsurefire.suiteXmlFiles=mac-only.xml
1212

1313
cache:
1414
directories:

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@
44
This project is using the latest Selenium Bindings.
55

66
## Setup
7+
78
Run these commands depending on your base OS.
89

910
### On Mac OS
1011

11-
Install Java JDK
12-
13-
Install Homebrew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
14-
15-
Install Caskroom `brew tap caskroom/cask`
16-
17-
If you dont have the Java Development Kit (JDK) run this command `brew cask install java`
18-
19-
Install Maven `brew install maven`
20-
21-
Run `./mac_install_browsers.sh`
12+
1. Install Homebrew `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
13+
2. Install Caskroom `brew tap caskroom/cask`
14+
3. If you dont have the Java Development Kit (JDK) run this command `brew cask install java`
15+
4. Install Maven `brew install maven`
16+
5. Run `./mac_install_browsers.sh`
2217

2318
## Running Tests
2419

2520
The following commands are instructions on how to run the tests
2621

2722
### From CLI
2823

29-
`mvn test -Dgroups=mac` on a mac
24+
`mvn test -Dsurefire.suiteXmlFiles=mac-only.xml ` on a mac
3025

3126
### Intellij Idea
3227

@@ -36,7 +31,7 @@ There is a shared run configuration that has the maven target setup and another
3631

3732
Safari requires the following steps to enable Selenium Webdriver tests to run:
3833

39-
1. Open Safari Prefrences
34+
1. Open Safari Preferences
4035
2. Go to the Advanced Tab
4136
3. Check the box at the bottom "Show Develop menu in menu bar"
4237
4. Click on the Develop menu

mac-only.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
3+
<suite name="Mac Test Suite" parallel="none">
4+
<test verbose="1" name="javajenkins">
5+
<groups>
6+
<run>
7+
<include name="mac"/>
8+
</run>
9+
</groups>
10+
<classes>
11+
<class name="LocalBrowsers.Chrome"/>
12+
<class name="LocalBrowsers.Edge"/>
13+
<class name="LocalBrowsers.Firefox"/>
14+
<class name="LocalBrowsers.PhantomJS"/>
15+
<class name="LocalBrowsers.Safari"/>
16+
</classes>
17+
</test> <!-- javajenkins -->
18+
</suite> <!-- Custom suite -->

src/test/java/LocalBrowsers/Chrome.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
import org.openqa.selenium.chrome.ChromeOptions;
66
import org.openqa.selenium.remote.DesiredCapabilities;
77
import org.testng.Assert;
8-
import org.testng.annotations.AfterTest;
9-
import org.testng.annotations.BeforeTest;
10-
import org.testng.annotations.Test;
8+
import org.testng.annotations.*;
119

1210
/**
1311
* Created by andrew on 12/3/16.
1412
*/
13+
@Test(groups = {"mac", "windows"})
1514
public class Chrome {
1615
WebDriver driver;
1716

@@ -22,8 +21,7 @@ public void chromeSetup(){
2221
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
2322
driver = new ChromeDriver(capabilities);
2423
}
25-
26-
@Test(groups = {"firefox", "chrome", "safari"})
24+
@Test
2725
public void test(){
2826
driver.get("http://lazycoder.io/about.html");
2927
Assert.assertEquals(driver.getTitle(), "About");

src/test/java/LocalBrowsers/Edge.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,21 @@
77
import org.openqa.selenium.edge.EdgeOptions;
88
import org.openqa.selenium.remote.DesiredCapabilities;
99
import org.testng.Assert;
10-
import org.testng.annotations.AfterTest;
11-
import org.testng.annotations.BeforeTest;
12-
import org.testng.annotations.Test;
10+
import org.testng.annotations.*;
1311

1412
/**
1513
* Created by andrew on 12/3/16.
1614
*/
1715
public class Edge {
1816
WebDriver driver;
1917

20-
@BeforeTest
18+
@BeforeClass
2119
public void edgeSetup(){
2220
DesiredCapabilities capabilities = DesiredCapabilities.edge();
2321
EdgeOptions options = new EdgeOptions();
2422
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
2523
driver = new EdgeDriver(capabilities);
2624
}
27-
2825
@Test(groups = {"windows"})
2926
public void test(){
3027
driver.get("http://lazycoder.io/about.html");

src/test/java/LocalBrowsers/Firefox.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66
import org.openqa.selenium.firefox.FirefoxProfile;
77
import org.openqa.selenium.remote.DesiredCapabilities;
88
import org.testng.Assert;
9-
import org.testng.annotations.AfterTest;
10-
import org.testng.annotations.BeforeTest;
11-
import org.testng.annotations.Test;
9+
import org.testng.annotations.*;
1210

1311
import java.io.File;
1412

1513
/**
1614
* Created by andrew on 12/3/16.
1715
*/
18-
16+
@Test(groups = {"mac", "windows"})
1917
public class Firefox {
2018
WebDriver driver;
2119

@@ -27,8 +25,7 @@ public void firefoxSetup() {
2725
FirefoxProfile ffp = new FirefoxProfile();
2826
driver = new FirefoxDriver(ff, ffp, capabilities);
2927
}
30-
31-
@Test(groups = {"mac", "windows"})
28+
@Test
3229
public void test(){
3330
driver.get("http://lazycoder.io/about.html");
3431
Assert.assertEquals(driver.getTitle(), "About");

src/test/java/LocalBrowsers/PhantomJS.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
import org.openqa.selenium.phantomjs.PhantomJSDriver;
55
import org.openqa.selenium.remote.DesiredCapabilities;
66
import org.testng.Assert;
7-
import org.testng.annotations.AfterTest;
8-
import org.testng.annotations.BeforeTest;
9-
import org.testng.annotations.Test;
7+
import org.testng.annotations.*;
108

119
/**
1210
* Created by andrew on 12/3/16.
1311
*/
12+
@Test(groups = {"mac", "windows"})
1413
public class PhantomJS {
1514
WebDriver driver;
1615

1716
@BeforeTest
1817
public void phantomJSSetup(){
1918
//DesiredCapabilities capabilities = new DesiredCapabilities.phantomjs();
20-
PhantomJSDriver d = new PhantomJSDriver();
19+
driver = new PhantomJSDriver();
2120
}
22-
23-
@Test(groups = {"mac", "windows"})
21+
@Test
2422
public void test(){
25-
driver.get("http://lazycoder.io/about.html");
23+
this.driver.get("http://lazycoder.io/about.html");
2624
Assert.assertEquals(driver.getTitle(), "About");
2725
}
2826

0 commit comments

Comments
 (0)