diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1a2116f..7f9f9ff 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,5 +1,5 @@
+#Cross Platform, Cross Browser test Run in parallel execution
name: Java CI with Maven
-
on:
pull_request:
branches: main
@@ -10,7 +10,7 @@ permissions:
id-token: write
actions: read
checks: write
-
+
jobs:
build:
name: Build On
@@ -18,65 +18,89 @@ jobs:
strategy:
max-parallel: 4
matrix:
- os: [ ubuntu-latest, windows-latest, macos-latest ]
-
+ os:
+ - ubuntu-latest
+ - windows-latest
+ - macos-latest
+
runs-on: ${{ matrix.os }}
steps:
- - name: Clone code from repo
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Set up JDK 17
- uses: actions/setup-java@v4
- with:
- java-version: '17'
- distribution: 'corretto'
- cache: maven
+ - name: Clone code from repo
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: "17"
+ distribution: corretto
+ cache: maven
+
+ - name: Cache m2 dependencies
+ uses: actions/cache@v4
+ with:
+ path: .m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
- - name: Cache m2 dependencies
- uses: actions/cache@v4
- with:
- path: .m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
-
- - name: Build with Maven
- run: mvn -B package --file pom.xml
+ - name: Build with Maven
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ run: mvn clean -e install -Dmaven.test.skip=true
- - name: Test with Maven
- run: mvn test
+ - name: Test Framework
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ run: mvn clean test -Dtest=FrameworkTest
- - name: Dorny Test Reporter
- uses: dorny/test-reporter@v1.9.1
- if: success() || failure()
- with:
- name: Test Report for ${{ matrix.os }}
- path: target/surefire-reports/TEST-*.xml
- reporter: java-junit
+ - name: Cross Browser Testing
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ run: mvn test -Dsurefire.suiteXmlFiles=xmlSuits/crossBrowser.xml
- - name: Load Allure test report history
- uses: actions/checkout@v4
- if: always()
- continue-on-error: true
- with:
- ref: gh-pages
- path: gh-pages
+ - name: Build and Test with Maven
+ if: ${{ matrix.os != 'ubuntu-latest' }}
+ run: mvn -B package --file pom.xml
- - name: Build Allure test report
- uses: simple-elf/allure-report-action@v1.7
- if: ${{ matrix.os == 'ubuntu-latest' }}
- with:
- gh_pages: gh-pages
- allure_history: allure-history
- allure_results: target/allure-results
+ - name: Dorny Test Reporter
+ uses: dorny/test-reporter@v1.9.1
+ if: success() || failure()
+ with:
+ name: Test Report for ${{ matrix.os }}
+ path: target/surefire-reports/TEST-*.xml
+ reporter: java-junit
- - name: Publish Allure test report
- uses: peaceiris/actions-gh-pages@v3
- if: ${{ matrix.os == 'ubuntu-latest' }}
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_branch: gh-pages
- publish_dir: allure-history
+ - name: Load Allure test report history
+ uses: actions/checkout@v4
+ if: always()
+ continue-on-error: true
+ with:
+ ref: gh-pages
+ path: gh-pages
+
+ - name: Build Allure test report
+ uses: simple-elf/allure-report-action@v1.7
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ with:
+ gh_pages: gh-pages
+ allure_history: allure-history
+ allure_results: target/allure-results
+
+ - name: Publish Allure test report
+ uses: peaceiris/actions-gh-pages@v3
+ if: ${{ matrix.os == 'ubuntu-latest' }}
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_branch: gh-pages
+ publish_dir: allure-history
+
+ check-java-code-style:
+ name: Check Java code style
+ runs-on: ubuntu-latest
+ steps:
+ - name: Clone code from repo
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Run java checkstyle
+ uses: nikitasavinov/checkstyle-action@0.6.0
diff --git a/README.md b/README.md
index 93762c7..5867777 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,3 @@
# LUMAJavaSeleniumTestNGAllure
+
[](https://github.com/ArinaJur/LUMAJavaSeleniumTestNGAllure/actions/workflows/build.yml)
diff --git a/pom.xml b/pom.xml
index b3d372e..b77b7e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,8 @@
2.24.0
1.9.20.1
+
+ false
@@ -67,13 +69,15 @@
maven-surefire-plugin
3.2.5
+ ${tests.skip}
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
-
- testng.xml
-
+ xmlSuits/smoke.xml
+ xmlSuits/chrome.xml
+ xmlSuits/chromium.xml
+ xmlSuits/regression.xml
diff --git a/src/main/java/com/lumatest/model/BagsPage.java b/src/main/java/com/lumatest/model/BagsPage.java
index 962262e..58d5fde 100644
--- a/src/main/java/com/lumatest/model/BagsPage.java
+++ b/src/main/java/com/lumatest/model/BagsPage.java
@@ -5,17 +5,17 @@
import org.openqa.selenium.WebDriver;
public class BagsPage extends SideMenu {
- private final String productNameXpath = "//img[@alt='";
- protected BagsPage(WebDriver driver) {
- super(driver);
- }
+ protected BagsPage(WebDriver driver) {
+ super(driver);
+ }
- @Step("Click '{productName}' Img.")
- public ProductPage clickProductImg(String productName) {
- String imgXpath = productNameXpath + productName + "']";
- getDriver().findElement(By.xpath(imgXpath)).click();
+ @Step("Click '{productName}' Img.")
+ public ProductPage clickProductImg(String productName) {
+ String productNameXpath = "//img[@alt='";
+ String imgXpath = productNameXpath + productName + "']";
+ getDriver().findElement(By.xpath(imgXpath)).click();
- return new ProductPage(getDriver());
- }
+ return new ProductPage(getDriver());
+ }
}
diff --git a/src/main/java/com/lumatest/model/BasePage.java b/src/main/java/com/lumatest/model/BasePage.java
index 4c3b356..cd62968 100644
--- a/src/main/java/com/lumatest/model/BasePage.java
+++ b/src/main/java/com/lumatest/model/BasePage.java
@@ -1,29 +1,28 @@
package com.lumatest.model;
+import java.time.Duration;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
-import java.time.Duration;
-
abstract class BasePage {
- private final WebDriver driver;
- private WebDriverWait wait;
+ private final WebDriver driver;
+ private WebDriverWait wait;
- protected BasePage(WebDriver driver) {
- this.driver = driver;
- PageFactory.initElements(driver, this);
- }
+ protected BasePage(WebDriver driver) {
+ this.driver = driver;
+ PageFactory.initElements(driver, this);
+ }
- protected WebDriver getDriver() {
- return this.driver;
- }
-
- protected WebDriverWait getWait() {
- if(wait == null) {
- this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
- }
+ protected WebDriver getDriver() {
+ return this.driver;
+ }
- return wait;
+ protected WebDriverWait getWait() {
+ if (wait == null) {
+ this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
+
+ return wait;
+ }
}
diff --git a/src/main/java/com/lumatest/model/BreadcrumbsMenu.java b/src/main/java/com/lumatest/model/BreadcrumbsMenu.java
index 4cbf5b2..77faef0 100644
--- a/src/main/java/com/lumatest/model/BreadcrumbsMenu.java
+++ b/src/main/java/com/lumatest/model/BreadcrumbsMenu.java
@@ -7,16 +7,16 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
abstract class BreadcrumbsMenu extends TopMenu {
- @FindBy(xpath = "//ul[@class='items']")
- private WebElement breadcrumbsMenu;
+ @FindBy(xpath = "//ul[@class='items']")
+ private WebElement breadcrumbsMenu;
- protected BreadcrumbsMenu(WebDriver driver) {
- super(driver);
- }
+ protected BreadcrumbsMenu(WebDriver driver) {
+ super(driver);
+ }
- @Step("Collect Breadcrumbs Menu Text.")
- public String getBreadcrumbsMenuText() {
+ @Step("Collect Breadcrumbs Menu Text.")
+ public String getBreadcrumbsMenuText() {
- return getWait().until(ExpectedConditions.visibilityOf(breadcrumbsMenu)).getText();
- }
+ return getWait().until(ExpectedConditions.visibilityOf(breadcrumbsMenu)).getText();
+ }
}
diff --git a/src/main/java/com/lumatest/model/GearPage.java b/src/main/java/com/lumatest/model/GearPage.java
index ae77536..449b34c 100644
--- a/src/main/java/com/lumatest/model/GearPage.java
+++ b/src/main/java/com/lumatest/model/GearPage.java
@@ -4,7 +4,7 @@
public class GearPage extends SideMenu {
- protected GearPage(WebDriver driver) {
- super(driver);
- }
+ protected GearPage(WebDriver driver) {
+ super(driver);
+ }
}
diff --git a/src/main/java/com/lumatest/model/HomePage.java b/src/main/java/com/lumatest/model/HomePage.java
index e9cf172..5e54f98 100644
--- a/src/main/java/com/lumatest/model/HomePage.java
+++ b/src/main/java/com/lumatest/model/HomePage.java
@@ -4,7 +4,7 @@
public class HomePage extends TopMenu {
- public HomePage(WebDriver driver) {
- super(driver);
- }
+ public HomePage(WebDriver driver) {
+ super(driver);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/lumatest/model/ProductPage.java b/src/main/java/com/lumatest/model/ProductPage.java
index 9a5fc80..14684c5 100644
--- a/src/main/java/com/lumatest/model/ProductPage.java
+++ b/src/main/java/com/lumatest/model/ProductPage.java
@@ -6,16 +6,16 @@
import org.openqa.selenium.support.FindBy;
public class ProductPage extends BreadcrumbsMenu {
- @FindBy(xpath = "//span[@data-ui-id='page-title-wrapper']")
- private WebElement productName;
+ @FindBy(xpath = "//span[@data-ui-id='page-title-wrapper']")
+ private WebElement productName;
- protected ProductPage(WebDriver driver) {
- super(driver);
- }
+ protected ProductPage(WebDriver driver) {
+ super(driver);
+ }
- @Step("Collect Actual Product Name Text.")
- public String getProductNameText() {
+ @Step("Collect Actual Product Name Text.")
+ public String getProductNameText() {
- return productName.getText();
- }
+ return productName.getText();
+ }
}
diff --git a/src/main/java/com/lumatest/model/SideMenu.java b/src/main/java/com/lumatest/model/SideMenu.java
index f1934e4..22e21d7 100644
--- a/src/main/java/com/lumatest/model/SideMenu.java
+++ b/src/main/java/com/lumatest/model/SideMenu.java
@@ -7,17 +7,17 @@
abstract class SideMenu extends BreadcrumbsMenu {
- @FindBy(linkText = "Bags")
- private WebElement bagsSideMenu;
+ @FindBy(linkText = "Bags")
+ private WebElement bagsSideMenu;
- protected SideMenu(WebDriver driver) {
- super(driver);
- }
+ protected SideMenu(WebDriver driver) {
+ super(driver);
+ }
- @Step("Click Bags Side Menu.")
- public BagsPage clickBagsSideMenu() {
- bagsSideMenu.click();
+ @Step("Click Bags Side Menu.")
+ public BagsPage clickBagsSideMenu() {
+ bagsSideMenu.click();
- return new BagsPage(getDriver());
- }
+ return new BagsPage(getDriver());
+ }
}
diff --git a/src/main/java/com/lumatest/model/TopMenu.java b/src/main/java/com/lumatest/model/TopMenu.java
index a473ad4..ae5eae6 100644
--- a/src/main/java/com/lumatest/model/TopMenu.java
+++ b/src/main/java/com/lumatest/model/TopMenu.java
@@ -1,23 +1,23 @@
package com.lumatest.model;
+import io.qameta.allure.Step;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
-import io.qameta.allure.Step;
abstract class TopMenu extends BasePage {
- @FindBy(linkText = "Gear")
- private WebElement gearTopMenu;
+ @FindBy(linkText = "Gear")
+ private WebElement gearTopMenu;
- protected TopMenu(WebDriver driver) {
- super(driver);
- }
+ protected TopMenu(WebDriver driver) {
+ super(driver);
+ }
- @Step("Click Gear Top Menu.")
- public GearPage clickGearTopMenu() {
- gearTopMenu.click();
+ @Step("Click Gear Top Menu.")
+ public GearPage clickGearTopMenu() {
+ gearTopMenu.click();
- return new GearPage(getDriver());
- }
+ return new GearPage(getDriver());
+ }
}
diff --git a/src/test/java/FrameworkTest.java b/src/test/java/FrameworkTest.java
index e2b35e3..104fc34 100644
--- a/src/test/java/FrameworkTest.java
+++ b/src/test/java/FrameworkTest.java
@@ -3,16 +3,15 @@
import org.testng.annotations.Test;
public class FrameworkTest {
- @Test
- public void testPass() {
+ @Test
+ public void testPass() {
- Assert.assertTrue(true);
- }
+ Assert.assertTrue(true);
+ }
- @Ignore
- @Test
- public void testFail() {
-
- Assert.assertTrue(false);
- }
+ @Ignore
+ @Test
+ public void testFail() {
+ Assert.fail();
+ }
}
diff --git a/src/test/java/com/lumatest/base/BaseTest.java b/src/test/java/com/lumatest/base/BaseTest.java
index b77f09d..b9b26fa 100644
--- a/src/test/java/com/lumatest/base/BaseTest.java
+++ b/src/test/java/com/lumatest/base/BaseTest.java
@@ -4,58 +4,67 @@
import com.lumatest.utils.ReportUtils;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
+import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.annotations.*;
public abstract class BaseTest {
- private WebDriver driver;
+ private WebDriver driver;
+ private final ThreadLocal threadLocalDriver = new ThreadLocal<>();
- @BeforeSuite
- protected void setupWebDriverManager() {
- WebDriverManager.chromedriver().setup();
-// WebDriverManager.firefoxdriver().setup();
+ @BeforeSuite
+ protected void setupWebDriverManager() {
+ WebDriverManager.chromedriver().setup();
+ WebDriverManager.firefoxdriver().setup();
+// WebDriverManager.edgedriver().setup();
+// WebDriverManager.operadriver().setup();
+// WebDriverManager.chromiumdriver().setup();
+// WebDriverManager.iedriver().setup();
+ }
-// WebDriverManager.edgedriver().setup();
-// WebDriverManager.operadriver().setup();
-// WebDriverManager.chromiumdriver().setup();
-// WebDriverManager.iedriver().setup();
- }
-
- @Parameters("browser")
- @BeforeMethod()
- protected void setupDriver(@Optional("chrome") String browser, ITestResult result) {
- Reporter.log("______________________________________________________________________", true);
- Reporter.log("RUN " + result.getMethod().getMethodName(), true);
+ @Parameters("browser")
+ @BeforeMethod(alwaysRun = true)
+ protected void setupDriver(@Optional("chrome") String browser, ITestContext context, ITestResult result) {
+ Reporter.log("______________________________________________________________________", true);
- this.driver = DriverUtils.createDriver(browser, this.driver);
+ this.driver = DriverUtils.createDriver(browser, this.driver);
+ this.threadLocalDriver.set(driver);
- if (getDriver() == null) {
- Reporter.log("ERROR: Unknown parameter 'browser' - '" + browser + "'.", true);
+ Reporter.log("Test Thread ID: " + Thread.currentThread().getId(), true);
+ Reporter.log("TEST SUIT: " + context.getCurrentXmlTest().getSuite().getName(), true);
+ Reporter.log("RUN " + result.getMethod().getMethodName(), true);
- System.exit(1);
- }
+ if (getDriver() == null) {
+ Reporter.log("ERROR: Unknown parameter 'browser' - '" + browser + "'.", true);
- Reporter.log("INFO: " + browser.toUpperCase() + " driver created.", true);
+ System.exit(1);
}
- @Parameters("browser")
- @AfterMethod(alwaysRun = true)
- protected void tearDown(@Optional("chrome") String browser, ITestResult result) {
- Reporter.log(result.getMethod().getMethodName() + ": " + ReportUtils.getTestStatus(result),
- true);
+ Reporter.log("INFO: " + browser.toUpperCase() + " driver created.", true);
+ }
- if (getDriver() != null) {
- getDriver().quit();
- Reporter.log("INFO: " + browser.toUpperCase() + " driver closed.", true);
+ @Parameters("browser")
+ @AfterMethod(alwaysRun = true)
+ protected void tearDown(@Optional("chrome") String browser, ITestResult result) {
+ Reporter.log(result.getMethod().getMethodName() + ": " + ReportUtils.getTestStatus(result),
+ true);
- this.driver = null;
- } else {
- Reporter.log("INFO: Driver is null.", true);
- }
- }
+ if (getDriver() != null) {
+ getDriver().quit();
+ Reporter.log("INFO: " + browser.toUpperCase() + " driver closed.", true);
- protected WebDriver getDriver() {
- return this.driver;
+ Reporter.log("After Test Thread ID: " + Thread.currentThread().getId(), true);
+ threadLocalDriver.remove();
+
+ driver = null;
+
+ } else {
+ Reporter.log("INFO: Driver is null.", true);
}
+ }
+
+ protected WebDriver getDriver() {
+ return threadLocalDriver.get();
+ }
}
diff --git a/src/test/java/com/lumatest/data/TestData.java b/src/test/java/com/lumatest/data/TestData.java
index b8e1658..e18982b 100644
--- a/src/test/java/com/lumatest/data/TestData.java
+++ b/src/test/java/com/lumatest/data/TestData.java
@@ -4,30 +4,31 @@
import org.testng.annotations.DataProvider;
public class TestData {
- public static final String BASE_URL = "https://magento.softwaretestingboard.com";
- public static final String BASE_URL_TITLE = "Home Page";
+ public static final String BASE_URL = "https://magento.softwaretestingboard.com";
+ public static final String BASE_URL_TITLE = "Home Page";
- public static class NavMenuData {
- public static final By WHATS_NEW_MENU = By.xpath("//nav//span[text()=\"What's New\"]");
- public static final String WHATS_NEW_URL = BASE_URL + "/what-is-new.html";
- public static final String WHATS_NEW_TITLE = "What's New";
- }
+ public static class NavMenuData {
+ public static final By WHATS_NEW_MENU = By.xpath("//nav//span[text()=\"What's New\"]");
+ public static final String WHATS_NEW_URL = BASE_URL + "/what-is-new.html";
+ public static final String WHATS_NEW_TITLE = "What's New";
+ }
- //all others menus
+ //all others menus
- public static final By SALE_MENU = By.xpath("//nav//span[text()='Sale']");
- public static final String SALE_URL = BASE_URL + "/sale.html";
- public static final String SALE_TITLE = "Sale";
+ public static final By SALE_MENU = By.xpath("//nav//span[text()='Sale']");
+ public static final String SALE_URL = BASE_URL + "/sale.html";
+ public static final String SALE_TITLE = "Sale";
- @DataProvider(name = "navigationData")
- public static Object[][] getNavMenuData() {
- return new Object[][] {
- {BASE_URL, NavMenuData.WHATS_NEW_MENU, NavMenuData.WHATS_NEW_URL, NavMenuData.WHATS_NEW_TITLE},
- {BASE_URL, SALE_MENU, SALE_URL, SALE_TITLE}
- };
- }
+ @DataProvider(name = "navigationData")
+ public static Object[][] getNavMenuData() {
+ return new Object[][]{
+ {BASE_URL, NavMenuData.WHATS_NEW_MENU, NavMenuData.WHATS_NEW_URL, NavMenuData.WHATS_NEW_TITLE},
+ {BASE_URL, SALE_MENU, SALE_URL, SALE_TITLE}
+ };
+ }
- //ProductPage
- public static final String DRIVEN_BACKPACK_PRODUCT_NAME = "Driven Backpack";
- public static final String DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU = "Home Gear Bags Driven Backpack";
+ //ProductPage
+ public static final String DRIVEN_BACKPACK_PRODUCT_URL = BASE_URL + "/driven-backpack.html";
+ public static final String DRIVEN_BACKPACK_PRODUCT_NAME = "Driven Backpack";
+ public static final String DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU = "Home Gear Bags Driven Backpack";
}
diff --git a/src/test/java/com/lumatest/test/NavigationTest.java b/src/test/java/com/lumatest/test/NavigationTest.java
index 614ba7e..2f57cad 100644
--- a/src/test/java/com/lumatest/test/NavigationTest.java
+++ b/src/test/java/com/lumatest/test/NavigationTest.java
@@ -2,68 +2,73 @@
import com.lumatest.base.BaseTest;
import com.lumatest.data.TestData;
-import io.qameta.allure.*;
+import io.qameta.allure.Link;
+import io.qameta.allure.Description;
+import io.qameta.allure.Severity;
+import io.qameta.allure.SeverityLevel;
+import io.qameta.allure.Story;
+import io.qameta.allure.Allure;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Test;
public class NavigationTest extends BaseTest {
- @Test(
- description = "TC-01 Open Base URL",
- groups = {"Smoke", "Regression"},
- testName = "NAVIGATION | Open Base URL"
- )
- @Story("Navigation")
- @Severity(SeverityLevel.BLOCKER)
- @Description("To verify that the base URL and title of the application are correct and as expected.")
- @Link(TestData.BASE_URL)
- public void testOpenBaseURL() {
- Allure.step("Set up expected results.");
- final String expectedURL = TestData.BASE_URL + "/";
- final String expectedTitle = TestData.BASE_URL_TITLE;
+ @Test(
+ testName = "NAVIGATION | Open Base URL",
+ description = "TC-01 Open Base URL",
+ groups = {"smoke", "regression"}
+ )
+ @Story("Navigation")
+ @Severity(SeverityLevel.BLOCKER)
+ @Description("To verify that the base URL and title of the application are correct and as expected.")
+ @Link(TestData.BASE_URL)
+ public void testOpenBaseURL() {
+ Allure.step("Set up expected results.");
+ final String expectedURL = TestData.BASE_URL + "/";
+ final String expectedTitle = TestData.BASE_URL_TITLE;
- Allure.step("Open base URL.");
- getDriver().get(TestData.BASE_URL);
+ Allure.step("Open base URL.");
+ getDriver().get(TestData.BASE_URL);
- Allure.step("Collect actual URL and actual title.");
- final String actualURL = getDriver().getCurrentUrl();
- final String actualTitle = getDriver().getTitle();
+ Allure.step("Collect actual URL and actual title.");
+ final String actualURL = getDriver().getCurrentUrl();
+ final String actualTitle = getDriver().getTitle();
- Allure.step("Verify that the actual URL is as expected.");
- Assert.assertEquals(actualURL, expectedURL);
- Allure.step("Verify that the actual title is as expected.");
- Assert.assertEquals(actualTitle, expectedTitle);
- }
+ Allure.step("Verify that the actual URL is as expected.");
+ Assert.assertEquals(actualURL, expectedURL);
+ Allure.step("Verify that the actual title is as expected.");
+ Assert.assertEquals(actualTitle, expectedTitle);
+ }
- @Test(
- groups = {"Smoke", "Regression"},
- description = "TC-02 Top Menu Navigation",
- dataProvider = "navigationData",
- dataProviderClass = TestData.class,
- testName = "NAVIGATION | Navigate to top menus"
- )
- @Story("Navigation")
- @Severity(SeverityLevel.CRITICAL)
- @Description("To verify that the top menu navigation on the website functions correctly by ensuring that " +
- "clicking on menu items directs the user to the expected URL with the expected title.")
- @Link(TestData.BASE_URL)
- public void testNavigationMenu(String baseURL, By navbarMenu, String expectedURL, String expectedTitle) {
- // {BASE_URL, WHATS_NEW_MENU, WHATS_NEW_URL, WHATS_NEW_TITLE},
- //{BASE_URL, SALE_MENU, SALE_URL, SALE_TITLE}
- Allure.step("Open Base URL");
- getDriver().get(baseURL);
+ @Test(
+ testName = "NAVIGATION | Navigate via top menus",
+ description = "TC-02 Top Menu Navigation",
+ dataProvider = "navigationData",
+ dataProviderClass = TestData.class,
+ groups = {"smoke", "regression"}
+ )
+ @Story("Navigation")
+ @Severity(SeverityLevel.CRITICAL)
+ @Description("To verify that the top menu navigation on the website functions correctly by ensuring that " +
+ "clicking on menu items directs the user to the expected URL with the expected title.")
+ @Link(TestData.BASE_URL)
+ public void testNavigationMenu(String baseURL, By navbarMenu, String expectedURL, String expectedTitle) {
+ // {BASE_URL, WHATS_NEW_MENU, WHATS_NEW_URL, WHATS_NEW_TITLE},
+ //{BASE_URL, SALE_MENU, SALE_URL, SALE_TITLE}
+ Allure.step("Open Base URL");
+ getDriver().get(baseURL);
- Allure.step("Click on " + navbarMenu.toString());
- getDriver().findElement(navbarMenu).click();
+ Allure.step("Click on " + navbarMenu.toString());
+ getDriver().findElement(navbarMenu).click();
- Allure.step("Collect actualURL, actualTitle");
- final String actualURL = getDriver().getCurrentUrl();
- final String actualTitle = getDriver().getTitle();
+ Allure.step("Collect actualURL, actualTitle");
+ final String actualURL = getDriver().getCurrentUrl();
+ final String actualTitle = getDriver().getTitle();
- Allure.step("Verify actualURL as expected");
- Assert.assertEquals(actualURL, expectedURL);
- Allure.step("Verify actualTitle as expected");
- Assert.assertEquals(actualTitle, expectedTitle);
- }
+ Allure.step("Verify actualURL as expected");
+ Assert.assertEquals(actualURL, expectedURL);
+ Allure.step("Verify actualTitle as expected");
+ Assert.assertEquals(actualTitle, expectedTitle);
+ }
}
diff --git a/src/test/java/com/lumatest/test/ProductPageTest.java b/src/test/java/com/lumatest/test/ProductPageTest.java
index 46546ef..af94808 100644
--- a/src/test/java/com/lumatest/test/ProductPageTest.java
+++ b/src/test/java/com/lumatest/test/ProductPageTest.java
@@ -4,33 +4,43 @@
import com.lumatest.data.TestData;
import com.lumatest.model.HomePage;
import com.lumatest.model.ProductPage;
-import io.qameta.allure.Allure;
+import io.qameta.allure.*;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ProductPageTest extends BaseTest {
- @Test
- public void testProduct() {
- Allure.step("Open Base URL.");
- getDriver().get(TestData.BASE_URL);
+ @Test(
+ testName = "PRODUCT | Product Details",
+ description = "TC-03 Verify Product Details on Product Page",
+ groups = {"regression"}
+ )
+ @Story("Product Details")
+ @Severity(SeverityLevel.NORMAL)
+ @Description("To verify that the product page displays the correct product name and breadcrumb menu text " +
+ "for the 'Driven Backpack'.")
+ @Link(TestData.DRIVEN_BACKPACK_PRODUCT_URL)
+ public void testProduct() {
+ Allure.step("Open Base URL.");
+ getDriver().get(TestData.BASE_URL);
- ProductPage productPage = new HomePage(getDriver())
- .clickGearTopMenu()
- .clickBagsSideMenu()
- .clickProductImg(TestData.DRIVEN_BACKPACK_PRODUCT_NAME);
+ ProductPage productPage =
+ new HomePage(getDriver())
+ .clickGearTopMenu()
+ .clickBagsSideMenu()
+ .clickProductImg(TestData.DRIVEN_BACKPACK_PRODUCT_NAME);
- final String productName = productPage.getProductNameText();
- final String breadcrumbsMenuText = productPage.getBreadcrumbsMenuText();
+ final String productName = productPage.getProductNameText();
+ final String breadcrumbsMenuText = productPage.getBreadcrumbsMenuText();
- Allure.step(
- "Verify actual '" + productName + "' equals to '" + TestData.DRIVEN_BACKPACK_PRODUCT_NAME + "'"
- );
- Assert.assertEquals(productName, TestData.DRIVEN_BACKPACK_PRODUCT_NAME);
+ Allure.step(
+ "Verify actual '" + productName + "' equals to '" + TestData.DRIVEN_BACKPACK_PRODUCT_NAME + "'"
+ );
+ Assert.assertEquals(productName, TestData.DRIVEN_BACKPACK_PRODUCT_NAME);
- Allure.step(
- "Verify actual '" + breadcrumbsMenuText + "' equals to '" + TestData.DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU + "'"
- );
- Assert.assertEquals(breadcrumbsMenuText, TestData.DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU);
- }
+ Allure.step(
+ "Verify actual '" + breadcrumbsMenuText + "' equals to '" + TestData.DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU + "'"
+ );
+ Assert.assertEquals(breadcrumbsMenuText, TestData.DRIVEN_BACKPACK_PRODUCT_PAGE_BREADCRUMBS_MENU);
+ }
}
diff --git a/src/test/java/com/lumatest/utils/DriverUtils.java b/src/test/java/com/lumatest/utils/DriverUtils.java
index 31e84cd..cd4a22c 100644
--- a/src/test/java/com/lumatest/utils/DriverUtils.java
+++ b/src/test/java/com/lumatest/utils/DriverUtils.java
@@ -1,5 +1,6 @@
package com.lumatest.utils;
+import java.util.Map;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
@@ -7,87 +8,82 @@
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
-import java.util.Map;
-
public class DriverUtils {
- private static final ChromeOptions chromeOptions;
- private static final FirefoxOptions firefoxOptions;
- private static final ChromiumOptions chromiumOptions;
+ private static final ChromeOptions chromeOptions;
+ private static final FirefoxOptions firefoxOptions;
+ private static final ChromiumOptions chromiumOptions;
- static {
- chromeOptions = new ChromeOptions();
- chromeOptions.addArguments("--incognito");
- chromeOptions.addArguments("--headless");
- chromeOptions.addArguments("--window-size=1920,1080");
- chromeOptions.addArguments("--disable-gpu");
- chromeOptions.addArguments("--no-sandbox");
- chromeOptions.addArguments("--disable-dev-shm-usage");
- chromeOptions.addArguments("--disable-web-security");
- chromeOptions.addArguments("--allow-running-insecure-content");
- chromeOptions.addArguments("--ignore-certificate-errors");
+ static {
+ chromeOptions = new ChromeOptions();
+ chromeOptions.addArguments("--incognito");
+ chromeOptions.addArguments("--headless");
+ chromeOptions.addArguments("--window-size=1920,1080");
+ chromeOptions.addArguments("--disable-gpu");
+ chromeOptions.addArguments("--no-sandbox");
+ chromeOptions.addArguments("--disable-dev-shm-usage");
+ chromeOptions.addArguments("--disable-web-security");
+ chromeOptions.addArguments("--allow-running-insecure-content");
+ chromeOptions.addArguments("--ignore-certificate-errors");
- firefoxOptions = new FirefoxOptions();
- firefoxOptions.addArguments("--incognito");
- firefoxOptions.addArguments("--headless");
- firefoxOptions.addArguments("--window-size=1920,1080");
- firefoxOptions.addArguments("--disable-gpu");
- firefoxOptions.addArguments("--no-sandbox");
- firefoxOptions.addArguments("--disable-dev-shm-usage");
- firefoxOptions.addArguments("--disable-web-security");
- firefoxOptions.addArguments("--allow-running-insecure-content");
- firefoxOptions.addArguments("--ignore-certificate-errors");
+ firefoxOptions = new FirefoxOptions();
+ firefoxOptions.addArguments("--incognito");
+ firefoxOptions.addArguments("--headless");
+ firefoxOptions.addArguments("--window-size=1920,1080");
+ firefoxOptions.addArguments("--disable-gpu");
+ firefoxOptions.addArguments("--no-sandbox");
+ firefoxOptions.addArguments("--disable-dev-shm-usage");
- chromiumOptions = chromeOptions;
- }
-
- private static WebDriver createChromeDriver(WebDriver driver) {
- if (driver != null) {
- driver.quit();
- }
- ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);
- chromeDriver.executeCdpCommand("Network.enable", Map.of());
- chromeDriver.executeCdpCommand(
- "Network.setExtraHTTPHeaders", Map.of("headers", Map.of("accept-language", "en-US,en;q=0.9"))
- );
+ chromiumOptions = chromeOptions;
+ }
- return chromeDriver ;
+ private static WebDriver createChromeDriver(WebDriver driver) {
+ if (driver != null) {
+ driver.quit();
}
+ ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);
+ chromeDriver.executeCdpCommand("Network.enable", Map.of());
+ chromeDriver.executeCdpCommand(
+ "Network.setExtraHTTPHeaders", Map.of("headers", Map.of("accept-language", "en-US,en;q=0.9"))
+ );
- private static WebDriver createChromiumDriver(WebDriver driver) {
- if (driver != null) {
- driver.quit();
- }
- ChromeDriver chromeDriver = new ChromeDriver((ChromeOptions) chromiumOptions);
- chromeDriver.executeCdpCommand("Network.enable", Map.of());
- chromeDriver.executeCdpCommand(
- "Network.setExtraHTTPHeaders", Map.of("headers", Map.of("accept-language", "en-US,en;q=0.9"))
- );
+ return chromeDriver;
+ }
- return chromeDriver ;
+ private static WebDriver createChromiumDriver(WebDriver driver) {
+ if (driver != null) {
+ driver.quit();
}
+ ChromeDriver chromeDriver = new ChromeDriver((ChromeOptions) chromiumOptions);
+ chromeDriver.executeCdpCommand("Network.enable", Map.of());
+ chromeDriver.executeCdpCommand(
+ "Network.setExtraHTTPHeaders", Map.of("headers", Map.of("accept-language", "en-US,en;q=0.9"))
+ );
- private static WebDriver createFirefoxDriver(WebDriver driver) {
- if (driver != null) {
- driver.quit();
- }
+ return chromeDriver;
+ }
- return new FirefoxDriver(firefoxOptions);
+ private static WebDriver createFirefoxDriver(WebDriver driver) {
+ if (driver != null) {
+ driver.quit();
}
- public static WebDriver createDriver(String browser, WebDriver driver) {
- switch(browser) {
- case "chrome" -> {
- return createChromeDriver(driver);
- }
- case "firefox" -> {
- return createFirefoxDriver(driver);
- }
- case "chromium" -> {
- return createChromiumDriver(driver);
- }
- default -> {
- return null;
- }
- }
+ return new FirefoxDriver(firefoxOptions);
+ }
+
+ public static WebDriver createDriver(String browser, WebDriver driver) {
+ switch (browser) {
+ case "chrome" -> {
+ return createChromeDriver(driver);
+ }
+ case "firefox" -> {
+ return createFirefoxDriver(driver);
+ }
+ case "chromium" -> {
+ return createChromiumDriver(driver);
+ }
+ default -> {
+ return null;
+ }
}
+ }
}
diff --git a/src/test/java/com/lumatest/utils/ReportUtils.java b/src/test/java/com/lumatest/utils/ReportUtils.java
index 83b0b12..604f32f 100644
--- a/src/test/java/com/lumatest/utils/ReportUtils.java
+++ b/src/test/java/com/lumatest/utils/ReportUtils.java
@@ -3,13 +3,13 @@
import org.testng.ITestResult;
public class ReportUtils {
- public static String getTestStatus(ITestResult result) {
- if (result.getStatus() == 1) {
- return "PASS";
- } else if(result.getStatus() == 2) {
- return "FAIL";
- }
-
- return "UNKNOWN";
+ public static String getTestStatus(ITestResult result) {
+ if (result.getStatus() == 1) {
+ return "PASS";
+ } else if (result.getStatus() == 2) {
+ return "FAIL";
}
+
+ return "UNKNOWN";
+ }
}
diff --git a/testng.xml b/testng.xml
deleted file mode 100644
index 2e8eba5..0000000
--- a/testng.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/xmlSuits/chrome.xml b/xmlSuits/chrome.xml
new file mode 100644
index 0000000..5d3a58f
--- /dev/null
+++ b/xmlSuits/chrome.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xmlSuits/chromium.xml b/xmlSuits/chromium.xml
new file mode 100644
index 0000000..690cbc9
--- /dev/null
+++ b/xmlSuits/chromium.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xmlSuits/crossBrowser.xml b/xmlSuits/crossBrowser.xml
new file mode 100644
index 0000000..6df7812
--- /dev/null
+++ b/xmlSuits/crossBrowser.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xmlSuits/firefox.xml b/xmlSuits/firefox.xml
new file mode 100644
index 0000000..6b63865
--- /dev/null
+++ b/xmlSuits/firefox.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xmlSuits/regression.xml b/xmlSuits/regression.xml
new file mode 100644
index 0000000..eb8a00b
--- /dev/null
+++ b/xmlSuits/regression.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/xmlSuits/smoke.xml b/xmlSuits/smoke.xml
new file mode 100644
index 0000000..db83632
--- /dev/null
+++ b/xmlSuits/smoke.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file