diff --git a/.github/workflows/gold.yml b/.github/workflows/gold.yml
new file mode 100644
index 0000000..66a2f73
--- /dev/null
+++ b/.github/workflows/gold.yml
@@ -0,0 +1,31 @@
+# This workflow will build a Java project with Maven
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Gold pipeline
+
+on:
+ push:
+ branches: [ ci3 ]
+ pull_request:
+ branches: [ ci3 ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+ - name: Run unit tests
+ run: mvn -Dtest=UnitTests test
+ - name: Run integration tests
+ run: mvn -Dtest=IntegrationTests test
+ - name: Run acceptance tests
+ env:
+ SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
+ SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
+ run: mvn -Dtest=*FeatureTest test
\ No newline at end of file
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 9ec7918..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
-name: Java CI with Maven
-
-on:
- push:
- branches:
- - cross_browser_sauce_bindings
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v1
- with:
- java-version: 11
- - name: Run acceptance tests
- env:
- SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
- SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
- run: |
- echo "$TEST_SECRET"
- mvn test -X -Dtest=AcceptanceTestDrivenAutomationTest
diff --git a/.github/workflows/silver.yml b/.github/workflows/silver.yml
new file mode 100644
index 0000000..4c6027f
--- /dev/null
+++ b/.github/workflows/silver.yml
@@ -0,0 +1,27 @@
+# This workflow will build a Java project with Maven
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Silver pipeline
+
+on:
+ push:
+ branches: [ ci3 ]
+ pull_request:
+ branches: [ ci3 ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+ - name: Run acceptance tests
+ env:
+ SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
+ SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
+ run: mvn -Dtest=*FeatureTest test
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 593e4b7..8f9b287 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,6 @@
org.ultimateqa
selenium.java
1.0-SNAPSHOT
-
@@ -20,6 +19,15 @@
11
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M4
+
+ all
+ 100
+
+
diff --git a/src/test/java/HelloSeleniumTest.java b/src/test/java/HelloSeleniumTest.java
deleted file mode 100644
index f48934a..0000000
--- a/src/test/java/HelloSeleniumTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-import org.junit.Test;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-
-public class HelloSeleniumTest {
- @Test
- public void firstTest()
- {
- //Telling the system where to find chromedriver. On Windows you also need to add .exe
- System.setProperty("webdriver.chrome.driver", "resources/chromedriver");
- WebDriver driver = new ChromeDriver();
- driver.get("https://www.saucedemo.com/");
- driver.quit();
- }
-}
diff --git a/src/test/java/advanced/tips/PageLoadTest.java b/src/test/java/advanced/tips/PageLoadTest.java
deleted file mode 100644
index 632af7e..0000000
--- a/src/test/java/advanced/tips/PageLoadTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package advanced.tips;
-
-import org.apache.commons.lang3.SystemUtils;
-import org.junit.After;
-import org.junit.Test;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-
-public class PageLoadTest {
- private WebDriver driver;
-
- @Test
- public void checkPageLoad() {
- driver = getDriver();
- driver.navigate().to("https://www.saucedemo.com/");
- }
-
- @After
- public void tearDown() {
- driver.quit();
- }
-
- private WebDriver getDriver() {
- if(SystemUtils.IS_OS_WINDOWS)
- {
- //The path of chromedriver for windows
- System.setProperty("webdriver.chrome.driver", "resources/windows/chromedriver.exe");
- }
- //Telling the system where to find chromedriver on mac
- System.setProperty("webdriver.chrome.driver", "resources/mac/chromedriver");
-
-
- return new ChromeDriver();
- }
-}
diff --git a/src/test/java/atda/AcceptanceTestDrivenAutomationTest.java b/src/test/java/atda/AcceptanceTestDrivenAutomationTest.java
deleted file mode 100644
index d92be23..0000000
--- a/src/test/java/atda/AcceptanceTestDrivenAutomationTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package atda;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-
-import static org.junit.Assert.assertTrue;
-
-public class AcceptanceTestDrivenAutomationTest {
- WebDriver driver;
- @Before
- public void setup()
- {
- driver = getDriver();
- }
- @After
- public void cleanup()
- {
- driver.quit();
- }
- @Test
- public void shouldOpen()
- {
- LoginPage loginPage = new LoginPage(driver);
- loginPage.open();
- assertTrue(loginPage.isLoaded());
- }
-
- @Test
- public void shouldLogin()
- {
- LoginPage loginPage = new LoginPage(driver);
- loginPage.open();
- assertTrue(loginPage.isLoaded());
-
- loginPage.login("standard_user", "secret_sauce");
- assertTrue(new ProductsPage(driver).isLoaded());
- }
-
- private WebDriver getDriver() {
- //Telling the system where to find chromedriver on mac
- //System.setProperty("webdriver.chrome.driver", "resources/mac/chromedriver");
-
- //The path of chromedriver for windows
- System.setProperty("webdriver.chrome.driver", "resources/windows/chromedriver.exe");
- return new ChromeDriver();
- }
-}
diff --git a/src/test/java/atda/BasePage.java b/src/test/java/atda/BasePage.java
deleted file mode 100644
index eef3e5b..0000000
--- a/src/test/java/atda/BasePage.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package atda;
-
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-public class BasePage {
- public final WebDriver driver;
- WebDriverWait wait;
-
-
- public BasePage(WebDriver driver) {
- this.driver = driver;
- wait = new WebDriverWait(driver, 10);
- }
-}
diff --git a/src/test/java/atda/LoginPage.java b/src/test/java/atda/LoginPage.java
deleted file mode 100644
index 3018565..0000000
--- a/src/test/java/atda/LoginPage.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package atda;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-public class LoginPage extends BasePage {
-
- public LoginPage(WebDriver driver) {
- super(driver);
- }
-
- public void open() {
- driver.get("http://www.saucedemo.com");
- }
-
- public boolean isLoaded() {
- return wait.until(ExpectedConditions.presenceOfElementLocated(By.id("user-name"))).isDisplayed();
- }
-
- public void login(String userName, String password) {
- driver.findElement(By.id("user-name")).sendKeys(userName);
- driver.findElement(By.id("password")).sendKeys(password);
- driver.findElement(By.className("btn_action")).submit();
- }
-}
diff --git a/src/test/java/atda/ProductsPage.java b/src/test/java/atda/ProductsPage.java
deleted file mode 100644
index b8152a6..0000000
--- a/src/test/java/atda/ProductsPage.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package atda;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-public class ProductsPage extends BasePage{
- public ProductsPage(WebDriver driver) {
- super(driver);
- }
-
- public boolean isLoaded() {
- return wait.until(
- ExpectedConditions.presenceOfElementLocated(By.id("inventory_filter_container"))).isDisplayed();
- }
-}
diff --git a/src/test/java/best/practices/Duplication.java b/src/test/java/best/practices/Duplication.java
deleted file mode 100644
index db26b68..0000000
--- a/src/test/java/best/practices/Duplication.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package best.practices;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import static org.junit.Assert.assertTrue;
-
-public class Duplication {
- WebDriver driver;
- @Before
- public void setup()
- {
- driver = getDriver();
- }
- @After
- public void cleanup()
- {
- driver.quit();
- }
- @Test
- public void test1() {
- driver.get("http://www.saucedemo.com");
- driver.findElement(By.id("user-name")).sendKeys("standard_user");
- driver.findElement(By.id("password")).sendKeys("secret_sauce");
- driver.findElement(By.className("btn_action")).submit();
- WebDriverWait wait = new WebDriverWait(driver, 10);
- boolean isDisplayed = wait.until(
- ExpectedConditions.presenceOfElementLocated(By.id("inventory_filter_container"))).isDisplayed();
- assertTrue(isDisplayed);
- }
- @Test
- public void test2() {
- driver.get("http://www.saucedemo.com");
- driver.findElement(By.id("user-name")).sendKeys("problem_user");
- driver.findElement(By.id("password")).sendKeys("secret_sauce");
- driver.findElement(By.className("btn_action")).submit();
- WebDriverWait wait = new WebDriverWait(driver, 10);
- boolean isDisplayed = wait.until(
- ExpectedConditions.presenceOfElementLocated(By.id("inventory_filter_container"))).isDisplayed();
- assertTrue(isDisplayed);
- }
- @Test
- public void test3() {
- open();
- typeText(By.id("user-name"), "standard_user");
- typeText(By.id("password"), "secret_sauce");
- clickButton(By.className("btn_action"));
- boolean isDisplayed = waitUntilDisplayed(By.id("inventory_filter_container"));
-
- assertTrue(isDisplayed);
- }
- @Test
- public void test4() {
- open();
- typeText(By.id("user-name"), "problem_user");
- typeText(By.id("password"), "secret_sauce");
- clickButton(By.className("btn_action"));
- boolean isDisplayed = waitUntilDisplayed(By.id("inventory_filter_container"));
-
- assertTrue(isDisplayed);
- }
- private boolean waitUntilDisplayed(By locator) {
- WebDriverWait wait = new WebDriverWait(driver, 10);
- return wait.until(
- ExpectedConditions.presenceOfElementLocated(locator)).isDisplayed();
- }
-
- private void clickButton(By locator) {
- driver.findElement(locator).submit();
- }
-
- private void typeText(By locator, String string) {
- driver.findElement(locator).sendKeys(string);
- }
-
- private void open() {
- driver.get("http://www.saucedemo.com");
- }
-
- private WebDriver getDriver() {
- //Telling the system where to find chromedriver. On Windows you also need to add .exe
- System.setProperty("webdriver.chrome.driver", "resources/chromedriver");
- return new ChromeDriver();
- }
-}
diff --git a/src/test/java/best/practices/LoginPage.java b/src/test/java/best/practices/LoginPage.java
deleted file mode 100644
index c6cb60c..0000000
--- a/src/test/java/best/practices/LoginPage.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package best.practices;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-
-public class LoginPage {
- //Private driver for a page object so that it's never accessible to our tests
- private WebDriver driver;
- //Private element locator that is never open to our tests
- private WebElement getUserNameField()
- {
- return driver.findElement(By.id("user-name"));
- }
- //Public login method, what the user does!
- public void login(String userName, String password) {
- getUserNameField().sendKeys(userName);
- driver.findElement(By.id("password")).sendKeys(password);
- driver.findElement(By.className("btn_action")).submit();
- }
-}
diff --git a/src/test/java/best/practices/PersonalInfoPage.java b/src/test/java/best/practices/PersonalInfoPage.java
deleted file mode 100644
index 4be6c03..0000000
--- a/src/test/java/best/practices/PersonalInfoPage.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package best.practices;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-
-public class PersonalInfoPage {
- //Private driver for a page object so that it's never accessible to our tests
- private WebDriver driver;
- //Private element locator that is never open to our tests
- private WebElement getFirstNameField()
- {
- return driver.findElement(By.id("FAKE LOCATOR"));
- }
- //Public login method, what the user does!
- public void fillOutPersonalInformation() {
- getFirstNameField().sendKeys("firstName");
- getLastNameField().sendKeys("firstName");
- getZipCodeField().sendKeys("firstName");
- }
-
- private WebElement getZipCodeField() {
- return driver.findElement(By.id("FAKE LOCATOR"));
- }
- private WebElement getLastNameField() {
- return driver.findElement(By.id("FAKE LOCATOR"));
- }
-}
diff --git a/src/test/java/best/practices/ProductsPage.java b/src/test/java/best/practices/ProductsPage.java
deleted file mode 100644
index e2f55cf..0000000
--- a/src/test/java/best/practices/ProductsPage.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package best.practices;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-
-public class ProductsPage {
- private WebDriver driver;
- private WebElement getShoppingCartElement()
- {
- return driver.findElement(By.id("BLABHLABHLJ"));
- }
- public void openShoppingCart() {
- getShoppingCartElement().click();
- }
-}
diff --git a/src/test/java/best/practices/ShoppingCartPage.java b/src/test/java/best/practices/ShoppingCartPage.java
deleted file mode 100644
index 8c81f13..0000000
--- a/src/test/java/best/practices/ShoppingCartPage.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package best.practices;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-
-public class ShoppingCartPage {
- //Private driver for a page object so that it's never accessible to our tests
- private WebDriver driver;
- //Private element locator that is never open to our tests
- private WebElement getCheckoutButton()
- {
- return driver.findElement(By.id("FAKE LOCATOR"));
- }
- //Public login method, what the user does!
- public void startCheckout() {
- getCheckoutButton().click();
- }
-}
diff --git a/src/test/java/best/practices/Synchronization.java b/src/test/java/best/practices/Synchronization.java
deleted file mode 100644
index 263aae9..0000000
--- a/src/test/java/best/practices/Synchronization.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package best.practices;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.util.concurrent.TimeUnit;
-
-public class Synchronization {
- WebDriver driver;
- String elementExistsInDOM = "https://the-internet.herokuapp.com/dynamic_loading/1";
- String elementRenderedAfter = "https://the-internet.herokuapp.com/dynamic_loading/2";
- By locator = By.id("finish");
- @Before
- public void setup()
- {
- driver = getDriver();
- }
- @After
- public void cleanup()
- {
- driver.quit();
- }
- @Test
- public void implicitWaitFindsHiddenElement() {
- driver.get(elementExistsInDOM);
- driver.findElement(locator);
- }
- @Test
- public void implicitWaitThrowsNoSuchElementException() {
- driver.get(elementRenderedAfter);
- driver.findElement(locator);
- }
- @Test
- public void configuredImplicitWait() {
- driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
- driver.get(elementRenderedAfter);
- driver.findElement(locator);
- }
- @Test(expected = org.openqa.selenium.TimeoutException.class)
- public void explicitWaitFixesImplicitWaitIssues() {
- driver.get(elementExistsInDOM);
- WebDriverWait wait = new WebDriverWait(driver, 5);
- wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
- }
- @Test
- public void explicitWaitWhenElementPresent() {
- driver.get(elementExistsInDOM);
- WebDriverWait wait = new WebDriverWait(driver, 5);
- wait.until(ExpectedConditions.presenceOfElementLocated(locator));
- }
- @Test
- public void correctSynchronization() {
- driver.get(elementRenderedAfter);
- WebDriverWait wait = new WebDriverWait(driver, 5);
- WebElement startButton =
- wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("start"))).findElement(By.xpath("//button"));
- startButton.click();
- WebElement helloWorldElement =
- wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("finish")));
- }
-
- private WebDriver getDriver() {
- //Telling the system where to find chromedriver. On Windows you also need to add .exe
- System.setProperty("webdriver.chrome.driver", "resources/chromedriver");
- return new ChromeDriver();
- }
-}
diff --git a/src/test/java/com/acceptance/BasePage.java b/src/test/java/com/acceptance/BasePage.java
new file mode 100644
index 0000000..cf56824
--- /dev/null
+++ b/src/test/java/com/acceptance/BasePage.java
@@ -0,0 +1,18 @@
+package com.acceptance;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+public class BasePage {
+ public final WebDriver driver;
+
+ public BasePage(WebDriver driver) {
+ this.driver = driver;
+ }
+ public boolean isElementDisplayed(By locator) {
+ WebDriverWait wait = new WebDriverWait(driver, 10);
+ return wait.until(ExpectedConditions.visibilityOfElementLocated(locator)).isDisplayed();
+ }
+}
diff --git a/src/test/java/com/acceptance/BaseTest.java b/src/test/java/com/acceptance/BaseTest.java
new file mode 100644
index 0000000..0955b49
--- /dev/null
+++ b/src/test/java/com/acceptance/BaseTest.java
@@ -0,0 +1,122 @@
+package com.acceptance;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.junit.runners.Parameterized;
+import org.openqa.selenium.MutableCapabilities;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.remote.CapabilityType;
+import org.openqa.selenium.remote.RemoteWebDriver;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+public class BaseTest {
+ public WebDriver driver;
+
+ @Rule
+ public SauceTestWatcher resultReportingTestWatcher = new SauceTestWatcher();
+
+ @Rule
+ public TestName testName = new TestName() {
+ public String getMethodName() {
+ return String.format("%s", super.getMethodName());
+ }
+ };
+
+ @Parameterized.Parameters
+ public static Collection