Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bc0b98d
isExpectedPage() changed
Apr 9, 2021
eb3934e
javadoc removed
Apr 12, 2021
e85219c
type changed to var
Apr 12, 2021
82964a0
step annotations changed
ufjena Apr 28, 2021
410e80c
pageobjects changed
ufjena Apr 28, 2021
11190ad
dataobjects changed
ufjena Apr 29, 2021
f02720e
project reworked
ufjena May 3, 2021
54cd243
isExpectedPage() - double use removed
ufjena May 4, 2021
db6ae4a
order changed for easier debugging
ufjena May 4, 2021
ca7a5f9
project reworked
ufjena May 7, 2021
ebe2311
project reworked
ufjena May 7, 2021
832d1ed
step annotations removed - test case added
ufjena May 7, 2021
a6363ec
RegisterPage changed
ufjena May 7, 2021
f6701fe
remove address form validation from AbstractBrowsingPage
oomelianchuk May 11, 2021
844c366
improve usage of AddressForm
oomelianchuk May 11, 2021
3588390
call isExpectedPage before returning page object
oomelianchuk May 19, 2021
04fcb79
remove return types from support flows
oomelianchuk May 19, 2021
6810e52
remove duplicated functionality and use updateCountOfProduct instead
oomelianchuk May 19, 2021
28c9a88
use forms to avoid code duplication
oomelianchuk May 19, 2021
9be2a4e
rename ~AddressForm to ~AddressContainer
oomelianchuk May 19, 2021
f35bbeb
improve toString method of Product
oomelianchuk May 19, 2021
79f2e79
improve naming of openProductdetailsPage
oomelianchuk May 19, 2021
4d84e10
return Product in updateCountOfProduct avoid product fetch
oomelianchuk May 20, 2021
6eb407c
remove ; from open page methods
oomelianchuk May 20, 2021
04ee4c9
remove TODO, method call in OrderSupport.openProductPageAndAddItoTheCart
oomelianchuk May 20, 2021
362ce7d
remove unneeded isExpectedPage call
oomelianchuk May 20, 2021
fa23796
remove unused method
oomelianchuk May 20, 2021
446951c
improve isComponentAvailable method of AddressForm
oomelianchuk May 20, 2021
4050880
add isPage method to check if the expected page is loaded without errors
oomelianchuk May 26, 2021
d02ffb4
check if account page is open while cleanup and don't open it again
oomelianchuk May 26, 2021
4c1865d
remove unneeded new line
oomelianchuk Jun 4, 2021
3dde365
improve removeProduct method
oomelianchuk Oct 1, 2021
bbaf053
fix toString method for Product
oomelianchuk Oct 1, 2021
4a07108
open mini cart before going to cart page
oomelianchuk Oct 1, 2021
e6c496d
remove isPage method
oomelianchuk Oct 1, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BrowseRandomVisualAssertSupport
@Given("^homepage is open")
public void openHomePageAndValidate()
{
HomePage homepage = OpenPageFlows.homepage();
var homepage = OpenPageFlows.homepage();
homepage.validateAndVisualAssert();
}

Expand All @@ -37,7 +37,7 @@ public void openRandomSubCategoryAndValidate(String seed)
random = new Random(Long.valueOf(seed));
}
String categoryName = new HomePage().topNav.getRandomSubcategoryName(random);
CategoryPage categoryPage = new HomePage().topNav.clickSubcategoryByName(categoryName);
var categoryPage = new HomePage().topNav.clickSubcategoryByName(categoryName);
categoryPage.isExpectedPage();
categoryPage.validateAndVisualAssert(categoryName);
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/posters/cucumber/support/CartSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public CartSupport(GlobalStorage storage)
@When("^I open the cart$")
public void openCart()
{
CartPage cartPage = new ProductdetailPage().miniCart.openCartPage();
var cartPage = new ProductdetailPage().miniCart.openCartPage();
cartPage.isExpectedPage();
}

@Then("^I see all the added products in the cart and their properties are correct$")
public void validateProductsInTheCart()
{
double subtotal = 0.0;
CartPage cartPage = new CartPage();
var cartPage = new CartPage();

for (Product product : storage.products)
{
Expand All @@ -41,7 +41,7 @@ public void validateProductsInTheCart()
@Then("^I can change amount of the \"([^\"]*)\" with \"([^\"]*)\" and \"([^\"]*)\" to (\\d+)$")
public void updateCountOfProduct(String productName, String size, String style, int amount)
{
CartPage cartPage = new CartPage();
var cartPage = new CartPage();
cartPage.updateProductCountByName(productName, style, size, amount);
for (Product product : storage.products)
{
Expand All @@ -57,7 +57,7 @@ public void updateCountOfProduct(String productName, String size, String style,
@Then("^I can remove \"([^\"]*)\" with \"([^\"]*)\" and \"([^\"]*)\"$")
public void removeProduct(String productName, String size, String style)
{
CartPage cartPage = new CartPage();
var cartPage = new CartPage();
cartPage.removeProductByName(productName, style, size);

storage.removeProduct(productName, style, size);
Expand Down
7 changes: 2 additions & 5 deletions src/test/java/posters/cucumber/support/GlobalStorage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.cucumber.support;

import java.util.ArrayList;
Expand Down Expand Up @@ -38,7 +35,7 @@ public Product addProduct(Product product)
// increase amount of product if already there or add the whole product
if (products.contains(product))
{
Product updatedProduct = products.get(products.indexOf(product));
var updatedProduct = products.get(products.indexOf(product));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oomelianchuk Please reuse updateCountOfProduct if possible. We should not implement the same functions again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

updatedProduct.setAmount(updatedProduct.getAmount() + 1);
return updatedProduct;
}
Expand All @@ -51,7 +48,7 @@ public Product addProduct(Product product)

public void removeProduct(String productName, String style, String size)
{
for (Product product : products)
for (var product : products)
{
if (product.getName().equals(productName) && product.getSize().equals(size)
&& product.getStyle().equals(style))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class HomePageSupport
@Step("validate homepage")
public void validateHomePage(String title)
{
HomePage homePage = new HomePage();
var homePage = new HomePage();
homePage.isExpectedPage();
homePage.title.validateTitle(title);
homePage.validateStructure();
Expand Down
8 changes: 3 additions & 5 deletions src/test/java/posters/cucumber/support/OpenPageFlows.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ public static HomePage homepage()
clearBrowserCookies();
// open home page
open(Neodymium.configuration().url());
HomePage homePage = new HomePage();
homePage.isExpectedPage();
return homePage;
return new HomePage().isExpectedPage();
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oomelianchuk Please remove the ; after functions. They are not needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@Given("^login page is loaded$")
@Step("open login page")
public static LoginPage loginPage()
{
// open login page and check for expected page
LoginPage loginPage = homepage().userMenu.openLogin();
var loginPage = homepage().userMenu.openLogin();
loginPage.isExpectedPage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to return loginPage.isExpectedPage(); so avoid one extra line

return loginPage;
};
Expand All @@ -42,7 +40,7 @@ public static LoginPage loginPage()
public static RegisterPage registerPage()
{
// open login page and check for expected page
RegisterPage registerPage = homepage().userMenu.openRegister();
var registerPage = homepage().userMenu.openRegister();
registerPage.isExpectedPage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to return loginPage.isExpectedPage(); so avoid one extra line

return registerPage;
};
Expand Down
50 changes: 25 additions & 25 deletions src/test/java/posters/cucumber/support/OrderSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ public OrderSupport(GlobalStorage storage)
@Given("^new user with \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" is registered and logged in$")
public void registerAndLogIn(String firstName, String lastName, String email, String password)
{
RegisterPage registerPage = OpenPageFlows.registerPage();
var registerPage = OpenPageFlows.registerPage();
registerPage.isExpectedPage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check all "Support" classes. We should have added the isExpectedPage already in the open function for the page. so a second call should not be needed.

storage.user = new User(firstName, lastName, email, password);
registerPage.sendRegisterForm(firstName, lastName, email, password, password);
LoginPage loginPage = registerPage.userMenu.openLogin();
var loginPage = registerPage.userMenu.openLogin();
loginPage.isExpectedPage();
loginPage.sendLoginform(email, password);
}

@Then("^all the products are to find in order history$")
public void validateOrderInOrderHistory()
{
AccountOverviewPage accountOverview = new HomePage().userMenu.openAccountOverview();
accountOverview.isExpectedPage();
OrderHistoryPage orderHistory = accountOverview.openOrderHistory();
var accountOverviewPage = new HomePage().userMenu.openAccountOverview();
accountOverviewPage.isExpectedPage();
var orderHistoryPage = accountOverviewPage.openOrderHistory();
for (Product product : storage.products)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent for structures like:

for (Product product : storage.products){...}

Decide if we use Product product : or var product : and adjust it at all occurrences.
BTW: I would use Product product : since this is a little bit more readable if you are working on class fields.

{
orderHistory.validateContainsProduct(product);
orderHistoryPage.validateContainsProduct(product);
}
}

Expand All @@ -65,25 +65,25 @@ public void openProductPageAndAddItoTheCart(String productUrl, String size, Stri
@When("I add this product with size \"([^\"]*)\" and style \"([^\"]*)\" to the cart$")
public void addProductToCart(String size, String style)
{
ProductdetailPage productPage = new ProductdetailPage();
productPage.setSize(size);
productPage.setStyle(style);
var productDetailPage = new ProductdetailPage();
productDetailPage.setSize(size);
productDetailPage.setStyle(style);

Product product = storage.addProduct(productPage.getProduct());
var product = storage.addProduct(productDetailPage.getProduct());

productPage.addToCart();
productPage.miniCart.openMiniCart();
productPage.miniCart.validateMiniCartByProduct(product);
productDetailPage.addToCart();
productDetailPage.miniCart.openMiniCart();
productDetailPage.miniCart.validateMiniCartByProduct(product);
}

@When("^I specify the shipping address \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" and use it for billing$")
public void openFillAndSendShippingFormUseForBilling(String name, String company, String address, String city, String state, String zip, String country)
{
CartPage cartPage = new ProductdetailPage().miniCart.openCartPage();
var cartPage = new ProductdetailPage().miniCart.openCartPage();
cartPage.isExpectedPage();
ShippingAddressPage shippingPage = cartPage.openShippingPage();
shippingPage.isExpectedPage();
shippingPage.sendShippingAddressForm(name, company, address, city, state, zip, country, true);
var shippingAddressPage = cartPage.openShippingPage();
shippingAddressPage.isExpectedPage();
shippingAddressPage.sendShippingAddressForm(name, company, address, city, state, zip, country, true);
storage.shippingAddress = new Address(name, company, address, city, state, zip, country);
storage.billingAddress = new Address(name, company, address, city, state, zip, country);
new PaymentPage().isExpectedPage();
Expand All @@ -92,31 +92,31 @@ public void openFillAndSendShippingFormUseForBilling(String name, String company
@When("^I enter payment data \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\"$")
public void fillAndSendPaymentForm(String name, String cardNumber, String month, String year)
{
PaymentPage paymentPage = new PaymentPage();
var paymentPage = new PaymentPage();
paymentPage.isExpectedPage();
PlaceOrderPage placeOrder = paymentPage.sendPaymentForm(cardNumber, name, month, year);
var placeOrderPage = paymentPage.sendPaymentForm(cardNumber, name, month, year);
storage.creditcard = new CreditCard(name, cardNumber, "xxxx xxxx xxxx " + cardNumber.substring(12, 16), month, year);
placeOrder.isExpectedPage();
placeOrderPage.isExpectedPage();
}

@Then("^I see all the products in order overview$")
public void validateContainsAllProductsWithCorrectPricesAndAmount()
{
double subtotal = 0.0;
PlaceOrderPage placeOrder = new PlaceOrderPage();
var placeOrderPage = new PlaceOrderPage();
for (Product product : storage.products)
{
placeOrder.validateContainsProduct(product);
placeOrderPage.validateContainsProduct(product);
subtotal += product.getTotalPrice();
}
placeOrder.validateSubtotal(PriceHelper.format(subtotal));
placeOrderPage.validateSubtotal(PriceHelper.format(subtotal));
}

@Then("^my shipping and billing addresses as well as payment data are displayed correctly")
public void validateAddressesAndPaymentData()
{
PlaceOrderPage placeOrder = new PlaceOrderPage();
placeOrder.validateAddressesAndPayment(storage.shippingAddress, storage.billingAddress, storage.creditcard);
var placeOrderPage = new PlaceOrderPage();
placeOrderPage.validateAddressesAndPayment(storage.shippingAddress, storage.billingAddress, storage.creditcard);
}

@Then("^my order is successfully placed$")
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/posters/cucumber/support/RegisterSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public void registerUserSetup()
@Step("delete user flow")
public LoginPage deleteUser()
{
HomePage homePage = new HomePage();
var homePage = new HomePage();
// ensure that the user is logged in
LoginPage loginPage;
var loginPage = new LoginPage();
if (!homePage.userMenu.isLoggedIn())
{
loginPage = homePage.userMenu.openLogin();
Expand All @@ -54,23 +54,23 @@ public LoginPage deleteUser()
// needed since there is a bug in posters
if (homePage.miniCart.getTotalCount() > 0)
{
CartPage cartPage = homePage.miniCart.openCartPage();
var cartPage = homePage.miniCart.openCartPage();
while (cartPage.hasProductsInCart())
{
cartPage.removeProduct(1);
}
}

// goto account page
AccountOverviewPage accountOverviewPage = homePage.userMenu.openAccountOverview();
var accountOverviewPage = homePage.userMenu.openAccountOverview();
accountOverviewPage.validateStructure();

// goto personal data page
PersonalDataPage personalDataPage = accountOverviewPage.openPersonalData();
var personalDataPage = accountOverviewPage.openPersonalData();
personalDataPage.validateStructure();

// goto account deletion page
DeleteAccountPage deleteAccountPage = personalDataPage.openDeleteAccount();
var deleteAccountPage = personalDataPage.openDeleteAccount();
deleteAccountPage.validateStructure();

// delete the account
Expand All @@ -88,9 +88,9 @@ public LoginPage deleteUser()

public static LoginPage registerUser(User user)
{
RegisterPage registerPage = OpenPageFlows.registerPage();
var registerPage = OpenPageFlows.registerPage();
registerPage.isExpectedPage();
LoginPage loginPage = registerPage.sendRegisterForm(user, user.getPassword());
var loginPage = registerPage.sendRegisterForm(user, user.getPassword());
loginPage.isExpectedPage();

return loginPage;
Expand All @@ -100,7 +100,7 @@ public static LoginPage registerUser(User user)
@Step("set up user and register him")
public void registerUser(String firstName, String lastName, String email, String password)
{
RegisterPage registerPage = new RegisterPage();
var registerPage = new RegisterPage();
registerPage.isExpectedPage();
storage.user = new User(firstName, lastName, email, password);
registerPage.sendRegisterForm(firstName, lastName, email, password, password);
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/posters/dataobjects/Address.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.dataobjects;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/posters/dataobjects/CreditCard.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.dataobjects;

/**
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/posters/dataobjects/Product.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.dataobjects;

import com.xceptance.neodymium.util.Neodymium;
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/posters/dataobjects/User.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.dataobjects;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.pageobjects.components;

import static com.codeborne.selenide.Condition.exist;
Expand Down
9 changes: 3 additions & 6 deletions src/test/java/posters/pageobjects/components/MiniCart.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
*
*/
package posters.pageobjects.components;

import static com.codeborne.selenide.Condition.exactText;
Expand Down Expand Up @@ -115,14 +112,14 @@ public void validateSubtotal(String subtotal)
* @param product
*/

@Step("validate \"{product}\" in the mini cart")
@Step("validate '{product}' in the mini cart")
public void validateMiniCart(int position, Product product)
{
validateMiniCart(position, product.getName(), product.getStyle(), product.getSize(), product.getAmount(),
PriceHelper.format(product.getTotalPrice()));
}

@Step("validate \"{product}\" in the mini cart by name")
@Step("validate '{product}' in the mini cart by name")
public void validateMiniCartByProduct(Product product)
{
SelenideElement productContainer = $$(".cartItems").filter(matchText(product.getCartRowRegex())).shouldHaveSize(1).first();
Expand All @@ -140,7 +137,7 @@ public void validateMiniCartByProduct(Product product)
* @param productAmount
* @param productTotalPrice
*/
@Step("validate \"{product}\" in the mini cart")
@Step("validate '{product}' in the mini cart")
public void validateMiniCart(int position, Product product, int productAmount, String productTotalPrice)
{
validateMiniCart(position, product.getName(), product.getStyle(), product.getSize(), productAmount, productTotalPrice);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/posters/pageobjects/components/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ public void isComponentAvailable()
searchField.should(exist);
}

@Step("search for \"{searchTerm}\" without result")
@Step("search for '{searchTerm}' without result")
public NoHitsPage noResult(String searchTerm)
{
search(searchTerm);
return new NoHitsPage();
}

@Step("search for \"{searchTerm}\" with result")
@Step("search for '{searchTerm}' with result")
public CategoryPage categoryPageResult(String searchTerm)
{
search(searchTerm);
return new CategoryPage();
}

@Step("search for \"{searchTerm}\"")
@Step("search for '{searchTerm}'")
public void search(String searchTerm)
{
openSearch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void isComponentAvailable()
successMessage.should(exist);
}

@Step("validate that the success message \"{message}\" is visible")
@Step("validate that the success message '{message}' is visible")
public void validateSuccessMessage(String message)
{
// Wait until javascript makes the success message visible
Expand Down
Loading