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 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..2872d8f --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +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 + +name: Java Selenium Maven Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.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();