Skip to content

Commit e149b7a

Browse files
Implementing CI/CD, fixed locator
Create maven.yml
2 parents cdced30 + 79d9516 commit e149b7a

5 files changed

Lines changed: 54 additions & 65 deletions

File tree

.github/workflows/maven-publish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/maven.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
name: Java Selenium Maven Tests
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up JDK
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: 17
21+
cache: maven
22+
- name: Build with Maven
23+
run: mvn -B package --file pom.xml

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/java/saucedemo/pageobjects/CheckoutStepTwo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class CheckoutStepTwo extends Cart {
1111

1212
private final By labelPriceItemsTotal = className("summary_subtotal_label");
1313
private final By labelPriceTax = className("summary_tax_label");
14-
private final By labelPriceTotal = xpath("//div[@class='summary_info_label summary_total_label']");
14+
private final By labelPriceTotal = xpath("//div[@data-test='total-label']");
1515
private final By labelPriceAllItemsValues = xpath("//*[@class='inventory_item_price']");
1616
private final By buttonCancel = id("cancel");
1717
private final By buttonFinish = id("finish");

src/test/java/saucedemo/tests/EndToEndTests.java

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,8 @@
33
import org.testng.annotations.BeforeMethod;
44
import org.testng.annotations.Test;
55
import saucedemo.base.BaseTest;
6-
import saucedemo.pageobjects.Cart;
7-
import saucedemo.pageobjects.CheckoutStepTwo;
8-
import saucedemo.pageobjects.Footer;
9-
import saucedemo.pageobjects.Header;
10-
import saucedemo.pageobjects.Login;
11-
import saucedemo.pageobjects.Menu;
12-
import saucedemo.pageobjects.OrderConfirmation;
13-
import saucedemo.pageobjects.Product;
14-
import saucedemo.pageobjects.Products;
15-
import saucedemo.steps.CartSteps;
16-
import saucedemo.steps.CheckoutOneSteps;
17-
import saucedemo.steps.CheckoutTwoSteps;
18-
import saucedemo.steps.LoginSteps;
19-
import saucedemo.steps.OrderConfirmationSteps;
20-
import saucedemo.steps.ProductSteps;
21-
import saucedemo.steps.ProductsSteps;
6+
import saucedemo.pageobjects.*;
7+
import saucedemo.steps.*;
228

239
import static org.hamcrest.MatcherAssert.assertThat;
2410
import static org.hamcrest.Matchers.is;
@@ -74,7 +60,6 @@ public void setup(){
7460
*/
7561
@Test(priority = 1)
7662
public void endToEndPlaceOrderWithOneProduct(){
77-
7863
productsSteps.addProductToCartAndGoToCart(randomNumber0ToTotalAvailableProducts());
7964
cart.clickCheckoutButton();
8065
checkoutOneSteps.fillInInputFieldsAndPressNext();
@@ -89,12 +74,10 @@ public void endToEndPlaceOrderWithOneProduct(){
8974
footer.checkSocialsAreDisplayed();
9075
menu.clickOnLogoutOption();
9176
login.checkAllPageElementsAreDisplayed();
92-
9377
}
9478

9579
@Test(priority = 2)
9680
public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){
97-
9881
int indexForFirst = randomNumber0ToTotalAvailableProducts();
9982
int indexForSecond = randomNumber0ToTotalAvailableProducts();
10083
int indexForThird = randomNumber0ToTotalAvailableProducts();
@@ -103,25 +86,18 @@ public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){
10386
productsSteps.setUpTheProducts();
10487
products.clickProductImage(indexForFirst);
10588
productSteps.checkPageElementsAreDisplayedExceptCartButtons();
106-
assertThat("The add to cart button is not displayed",
107-
product.isAddToCartButtonDisplayed(), is(true));
89+
assertThat("The add to cart button is not displayed", product.isAddToCartButtonDisplayed(), is(true));
10890
productSteps.checkTheProductPageContents(productsOrdered.get(indexForFirst));
109-
assertThat("The badge is displayed over the cart icon",
110-
header.isBadgeDisplayed(), is(false));
91+
assertThat("The badge is displayed over the cart icon", header.isBadgeDisplayed(), is(false));
11192
product.clickAddToCart();
112-
assertThat("The remove from cart button is not displayed",
113-
product.isRemoveFromCartButtonDisplayed(), is(true));
114-
assertThat("The badge is not displayed over the cart icon",
115-
header.isBadgeDisplayed(), is(true));
116-
assertThat("The badge value is not as expected",
117-
header.getCartBadgeValue(), is(++numberOfProductsInCart));
93+
assertThat("The remove from cart button is not displayed", product.isRemoveFromCartButtonDisplayed(), is(true));
94+
assertThat("The badge is not displayed over the cart icon", header.isBadgeDisplayed(), is(true));
95+
assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart));
11896
product.clickBackToProducts();
11997
products.clickAddToCart(indexForSecond);
120-
assertThat("The badge value is not as expected",
121-
header.getCartBadgeValue(), is(++numberOfProductsInCart));
98+
assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart));
12299
products.clickAddToCart(indexForThird);
123-
assertThat("The badge value is not as expected",
124-
header.getCartBadgeValue(), is(++numberOfProductsInCart));
100+
assertThat("The badge value is not as expected", header.getCartBadgeValue(), is(++numberOfProductsInCart));
125101
header.clickCartButton();
126102
cart.clickProductRemoveButton(0);
127103
cart.clickCheckoutButton();
@@ -130,8 +106,7 @@ public void endToEndPlaceOrderWithMultipleProductsCheckTotal(){
130106
checkoutTwoSteps.checkTotalSumValueOfProducts();
131107
checkoutStepTwo.clickFinishButton();
132108
confirmationSteps.checkPageIsDisplayed();
133-
assertThat("The badge is displayed over the cart icon",
134-
header.isBadgeDisplayed(), is(false));
109+
assertThat("The badge is displayed over the cart icon", header.isBadgeDisplayed(), is(false));
135110
confirmation.clickBackHomeButton();
136111
header.checkTitleIsDisplayed();
137112
productsSteps.checkPageIsDisplayed();

0 commit comments

Comments
 (0)