From a91911154db7b83dda8a656bcc053dec6b8a6678 Mon Sep 17 00:00:00 2001 From: Adrian Ciuciui <31804204+AdrianCiuciui@users.noreply.github.com> Date: Sun, 13 Apr 2025 11:15:05 +0300 Subject: [PATCH 1/4] Create maven.yml --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..c6bb036 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From c19b7db5d9ff0cfd974503cc61e0922cfb608b94 Mon Sep 17 00:00:00 2001 From: Adrian Ciuciui Date: Sun, 13 Apr 2025 13:30:32 +0300 Subject: [PATCH 2/4] Fixed a locator Minor code beautification --- .idea/jarRepositories.xml | 20 +++++++++ .../pageobjects/CheckoutStepTwo.java | 2 +- .../java/saucedemo/tests/EndToEndTests.java | 45 +++++-------------- 3 files changed, 31 insertions(+), 36 deletions(-) create mode 100644 .idea/jarRepositories.xml diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java b/src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java index 1d3404c..4a69651 100644 --- a/src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java +++ b/src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java @@ -11,7 +11,7 @@ public class CheckoutStepTwo extends Cart { private final By labelPriceItemsTotal = className("summary_subtotal_label"); private final By labelPriceTax = className("summary_tax_label"); - private final By labelPriceTotal = xpath("//div[@class='summary_info_label summary_total_label']"); + private final By labelPriceTotal = xpath("//div[@data-test='total-label']"); private final By labelPriceAllItemsValues = xpath("//*[@class='inventory_item_price']"); private final By buttonCancel = id("cancel"); private final By buttonFinish = id("finish"); diff --git a/src/test/java/saucedemo/tests/EndToEndTests.java b/src/test/java/saucedemo/tests/EndToEndTests.java index 6cbe6c8..c3118b7 100644 --- a/src/test/java/saucedemo/tests/EndToEndTests.java +++ b/src/test/java/saucedemo/tests/EndToEndTests.java @@ -3,22 +3,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import saucedemo.base.BaseTest; -import saucedemo.pageobjects.Cart; -import saucedemo.pageobjects.CheckoutStepTwo; -import saucedemo.pageobjects.Footer; -import saucedemo.pageobjects.Header; -import saucedemo.pageobjects.Login; -import saucedemo.pageobjects.Menu; -import saucedemo.pageobjects.OrderConfirmation; -import saucedemo.pageobjects.Product; -import saucedemo.pageobjects.Products; -import saucedemo.steps.CartSteps; -import saucedemo.steps.CheckoutOneSteps; -import saucedemo.steps.CheckoutTwoSteps; -import saucedemo.steps.LoginSteps; -import saucedemo.steps.OrderConfirmationSteps; -import saucedemo.steps.ProductSteps; -import saucedemo.steps.ProductsSteps; +import saucedemo.pageobjects.*; +import saucedemo.steps.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -74,7 +60,6 @@ public void setup(){ */ @Test(priority = 1) public void endToEndPlaceOrderWithOneProduct(){ - productsSteps.addProductToCartAndGoToCart(randomNumber0ToTotalAvailableProducts()); cart.clickCheckoutButton(); checkoutOneSteps.fillInInputFieldsAndPressNext(); @@ -89,12 +74,10 @@ public void endToEndPlaceOrderWithOneProduct(){ footer.checkSocialsAreDisplayed(); menu.clickOnLogoutOption(); login.checkAllPageElementsAreDisplayed(); - } @Test(priority = 2) public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){ - int indexForFirst = randomNumber0ToTotalAvailableProducts(); int indexForSecond = randomNumber0ToTotalAvailableProducts(); int indexForThird = randomNumber0ToTotalAvailableProducts(); @@ -103,25 +86,18 @@ public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){ productsSteps.setUpTheProducts(); products.clickProductImage(indexForFirst); productSteps.checkPageElementsAreDisplayedExceptCartButtons(); - assertThat("The add to cart button is not displayed", - product.isAddToCartButtonDisplayed(), is(true)); + assertThat("The add to cart button is not displayed", product.isAddToCartButtonDisplayed(), is(true)); productSteps.checkTheProductPageContents(productsOrdered.get(indexForFirst)); - assertThat("The badge is displayed over the cart icon", - header.isBadgeDisplayed(), is(false)); + assertThat("The badge is displayed over the cart icon", header.isBadgeDisplayed(), is(false)); product.clickAddToCart(); - assertThat("The remove from cart button is not displayed", - product.isRemoveFromCartButtonDisplayed(), is(true)); - assertThat("The badge is not displayed over the cart icon", - header.isBadgeDisplayed(), is(true)); - assertThat("The badge value is not as expected", - header.getCartBadgeValue(), is(++numberOfProductsInCart)); + assertThat("The remove from cart button is not displayed", product.isRemoveFromCartButtonDisplayed(), is(true)); + assertThat("The badge is not displayed over the cart icon", header.isBadgeDisplayed(), is(true)); + assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart)); product.clickBackToProducts(); products.clickAddToCart(indexForSecond); - assertThat("The badge value is not as expected", - header.getCartBadgeValue(), is(++numberOfProductsInCart)); + assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart)); products.clickAddToCart(indexForThird); - assertThat("The badge value is not as expected", - header.getCartBadgeValue(), is(++numberOfProductsInCart)); + assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart)); header.clickCartButton(); cart.clickProductRemoveButton(0); cart.clickCheckoutButton(); @@ -130,8 +106,7 @@ public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){ checkoutTwoSteps.checkTotalSumValueOfProducts(); checkoutStepTwo.clickFinishButton(); confirmationSteps.checkPageIsDisplayed(); - assertThat("The badge is displayed over the cart icon", - header.isBadgeDisplayed(), is(false)); + assertThat("The badge is displayed over the cart icon", header.isBadgeDisplayed(), is(false)); confirmation.clickBackHomeButton(); header.checkTitleIsDisplayed(); productsSteps.checkPageIsDisplayed(); From 7895b33c7770199100531d62c42e70192702e7d9 Mon Sep 17 00:00:00 2001 From: Adrian Ciuciui <31804204+AdrianCiuciui@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:04:33 +0300 Subject: [PATCH 3/4] Delete .github/workflows/maven-publish.yml --- .github/workflows/maven-publish.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml deleted file mode 100644 index 6d2a763..0000000 --- a/.github/workflows/maven-publish.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path - -name: Run Tests for the Project - -on: - push: - branches: - - master - pull_request: - branches: - - master - workflow_dispatch: - -jobs: - tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - cache: maven - - name: Run tests - run: mvn test From 79d95162cb97ac1d0eb6264dcb2b3e6f503cf0f0 Mon Sep 17 00:00:00 2001 From: Adrian Ciuciui <31804204+AdrianCiuciui@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:14:25 +0300 Subject: [PATCH 4/4] Update maven.yml --- .github/workflows/maven.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c6bb036..2872d8f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,35 +1,23 @@ # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Java CI with Maven +name: Java Selenium Maven Tests on: push: - branches: [ "master" ] + branches: [ main ] pull_request: - branches: [ "master" ] + branches: [ main ] jobs: - build: - + test: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: '17' - distribution: 'temurin' + java-version: 17 cache: maven - name: Build with Maven run: mvn -B package --file pom.xml - - # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6