Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/workflows/maven-publish.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
45 changes: 10 additions & 35 deletions src/test/java/saucedemo/tests/EndToEndTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,7 +60,6 @@ public void setup(){
*/
@Test(priority = 1)
public void endToEndPlaceOrderWithOneProduct(){

productsSteps.addProductToCartAndGoToCart(randomNumber0ToTotalAvailableProducts());
cart.clickCheckoutButton();
checkoutOneSteps.fillInInputFieldsAndPressNext();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down