Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type to var #6

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions config/localization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ default:
successfulAccountCreation: Your account has been created. Log in with your email address and password.
emailDoesNotExistError: The email address you entered doesn't exist. Please try again.
incorrectPasswordError: The password you entered is incorrect. Please try again.
CheckoutPages:
shippingAddressFormTitle: Enter a shipping address
newShippingAddressFormTitle: Add a new shipping address
billingAddressFormTitle: Enter a billing address
newBillingAddressFormTitle: Add a new billing address
General:
addresses:
fullname: Full name*
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/posters/cucumber/features/Order.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,29 @@ Feature: Order
Given "<browser>" is open
And product page "<productUrl>" is open
When I add this product with size "<productSize>" and style "<productStyle>" to the cart
And I specify the shipping address "<name>", "<company>", "<address>", "<city>", "<state>", "<zip>", "<country>" and use it for billing
And I specify the shipping address "<firstName>", "<lastName>", "<name>", "<company>", "<address>", "<city>", "<state>", "<zip>", "<country>", "<sameBillingAddress>" and use it for billing
And I enter payment data "<name>", "<cardNumber>", "<month>", "<year>"
Then I see all the products in order overview
And my shipping and billing addresses as well as payment data are displayed correctly
And my order is successfully placed

@Chrome
Examples:
| browser | productUrl | productSize | productStyle | name | company | address | city | state | zip | country | cardNumber | month | year |
| Chrome_1024x768 | productDetail/Grizzly%20Bear?productId=1 | 32 x 24 in | gloss | James | Monster Corporation | 621 Wall St | North Tonawada | New York | 14120 | United States | 4111111111111111 | 05 | 2021 |
| browser | productUrl | productSize | productStyle | firstName | lastName | name | company | address | city | state | zip | country | cardNumber | month | year | sameBillingAddress |
| Chrome_1024x768 | productDetail/Grizzly%20Bear?productId=1 | 32 x 24 in | gloss | Jakobi | Doe | James | Monster Corporation | 621 Wall St | North Tonawada | New York | 14120 | United States | 4111111111111111 | 05 | 2021 | false |
| Chrome_1024x768 | productDetail/Grizzly%20Bear?productId=1 | 32 x 24 in | gloss | Jakobi | Doe | James | Monster Corporation | 621 Wall St | North Tonawada | New York | 14120 | United States | 4111111111111111 | 05 | 2021 | true |

@Firefox
Examples:
| browser | productUrl | productSize | productStyle | name | company | address | city | state | zip | country | cardNumber | month | year |
| Firefox_1024x768 | productDetail/Grizzly%20Bear?productId=1 | 32 x 24 in | gloss | James | Monster Corporation | 621 Wall St | North Tonawada | New York | 14120 | United States | 4111111111111111 | 05 | 2021 |
| browser | productUrl | productSize | productStyle | firstName | lastName | name | company | address | city | state | zip | country | cardNumber | month | year | sameBillingAddress |
| Firefox_1024x768 | productDetail/Grizzly%20Bear?productId=1 | 32 x 24 in | gloss | Jakobi | Doe | James | Monster Corporation | 621 Wall St | North Tonawada | New York | 14120 | United States | 4111111111111111 | 05 | 2021 | false |

@DeleteUserAfterwards
Scenario Outline: Order some products as User
Scenario Outline: Order some products as registered User
Given "<browser>" is open
And new user with "<firstName>", "<lastName>", "<email>", "<password>" is registered and logged in
When I add product "<productUrl>" in size "<productSize>" and style "<productStyle>"
And I specify the shipping address "<name>", "<company>", "<address>", "<city>", "<state>", "<zip>", "<country>" and use it for billing
And I specify the shipping address "<firstName>", "<lastName>", "<name>", "<company>", "<address>", "<city>", "<state>", "<zip>", "<country>", "<sameBillingAddress>" and use it for billing
And I enter payment data "<name>", "<cardNumber>", "<month>", "<year>"
Then I see all the products in order overview
And my shipping and billing addresses as well as payment data are displayed correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.cucumber.java.en.When;
import posters.pageobjects.pages.browsing.CategoryPage;
import posters.pageobjects.pages.browsing.HomePage;
import posters.pageobjects.pages.browsing.ProductdetailPage;
import posters.pageobjects.pages.browsing.ProductDetailPage;

public class BrowseRandomVisualAssertSupport
{
Expand All @@ -21,8 +21,8 @@ public class BrowseRandomVisualAssertSupport
@Given("^homepage is open")
public void openHomePageAndValidate()
{
HomePage homepage = OpenPageFlows.homepage();
homepage.validateAndVisualAssert();
var homePage = OpenPageFlows.homePage();
homePage.validateAndVisualAssert();
}

@When("^I choose random sub category with seed \"([^\"]*)\"$")
Expand All @@ -37,8 +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);
categoryPage.isExpectedPage();
var categoryPage = new HomePage().topNav.clickSubcategoryByName(categoryName);
categoryPage.validateAndVisualAssert(categoryName);
}

Expand All @@ -52,7 +51,7 @@ public void openRandomProduct()
@Then("^I see correct product")
public void validateProduct()
{
new ProductdetailPage().validateAndVisualAssert(productName);
new ProductDetailPage().validateAndVisualAssert(productName);
}

}
26 changes: 9 additions & 17 deletions src/test/java/posters/cucumber/support/CartSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import posters.dataobjects.Product;
import posters.pageobjects.pages.browsing.ProductdetailPage;
import posters.pageobjects.pages.browsing.ProductDetailPage;
import posters.pageobjects.pages.checkout.CartPage;
import posters.pageobjects.utility.PriceHelper;

Expand All @@ -20,15 +20,14 @@ public CartSupport(GlobalStorage storage)
@When("^I open the cart$")
public void openCart()
{
CartPage cartPage = new ProductdetailPage().miniCart.openCartPage();
cartPage.isExpectedPage();
new ProductDetailPage().miniCart.openCartPage();
}

@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 @@ -39,25 +38,18 @@ 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)
public void updateCountOfProduct(String name, String size, String style, int amount)
{
CartPage cartPage = new CartPage();
cartPage.updateProductCountByName(productName, style, size, amount);
for (Product product : storage.products)
{
if (product.getName().equals(productName) && product.getSize().equals(size)
&& product.getStyle().equals(style))
{
product.setAmount(amount);
}
cartPage.validateContainsProduct(product);
}
var cartPage = new CartPage();
cartPage.updateProductCountByName(name, style, size, amount);

storage.updateCountOfProduct(name, size, style, amount);
}

@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
32 changes: 22 additions & 10 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,9 +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));
updatedProduct.setAmount(updatedProduct.getAmount() + 1);
return updatedProduct;
return updateCountOfProduct(product.getName(), product.getSize(), product.getStyle(), product.getAmount() + 1);
}
else
{
Expand All @@ -49,15 +44,32 @@ public Product addProduct(Product product)
}
}

public void removeProduct(String productName, String style, String size)
public Product getProductFromArrayList(String name, String size, String style)
{
int i = 0;
for (Product product : products)
{
if (product.getName().equals(productName) && product.getSize().equals(size)
&& product.getStyle().equals(style))
if (product.getName().equals(name) && product.getSize().equals(size) && product.getStyle().equals(style))
{
products.remove(product);
i = products.indexOf(product);
}
}
return products.get(i);
}

public Product updateCountOfProduct(String name, String size, String style, int amount)
{
var product = getProductFromArrayList(name, size, style);
String unitPrice = product.getUnitPrice();
products.remove(products.indexOf(product));
product = new Product(name, unitPrice, style, size, amount);
products.add(product);
return product;
}

public void removeProduct(String name, String style, String size)
{
var product = getProductFromArrayList(name, size, style);
products.remove(product);
}
}
5 changes: 1 addition & 4 deletions src/test/java/posters/cucumber/support/HomePageSupport.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package posters.cucumber.support;

import io.cucumber.java.en.Then;
import io.qameta.allure.Step;
import posters.pageobjects.pages.browsing.HomePage;

public class HomePageSupport
{
@Then("^I see homepage with logo, carousel, hot products and footer and it's title is \"([^\"]*)\"$")
@Step("validate homepage")
public void validateHomePage(String title)
{
HomePage homePage = new HomePage();
homePage.isExpectedPage();
var homePage = new HomePage();
homePage.title.validateTitle(title);
homePage.validateStructure();
homePage.footer.validate();
Expand Down
36 changes: 12 additions & 24 deletions src/test/java/posters/cucumber/support/OpenPageFlows.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,48 @@
import com.xceptance.neodymium.util.Neodymium;

import io.cucumber.java.en.Given;
import io.qameta.allure.Step;
import posters.pageobjects.pages.browsing.HomePage;
import posters.pageobjects.pages.browsing.ProductdetailPage;
import posters.pageobjects.pages.browsing.ProductDetailPage;
import posters.pageobjects.pages.user.LoginPage;
import posters.pageobjects.pages.user.RegisterPage;

public class OpenPageFlows
{
@Given("^homepage is loaded$")
@Step("open home page")
public static HomePage homepage()
public static HomePage homePage()
{
// clear cookies to ensure a new session
clearBrowserCookies();
// open home page
open(Neodymium.configuration().url());
HomePage homePage = new HomePage();
homePage.isExpectedPage();
return homePage;
};
return new HomePage().isExpectedPage();
}

@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();
loginPage.isExpectedPage();
return loginPage;
};
return homePage().userMenu.openLogin();
}

@Given("^register page is loaded$")
@Step("open register page")
public static RegisterPage registerPage()
{
// open login page and check for expected page
RegisterPage registerPage = homepage().userMenu.openRegister();
registerPage.isExpectedPage();
return registerPage;
};
return homePage().userMenu.openRegister();
}

@Given("^product page \"([^\"]*)\" is open$")
@Step("open product page with cleared cookes")
public static ProductdetailPage openProductdetailsPageWithClearedCookes(String url)
public static ProductDetailPage openProductDetailsPageWithClearedCookes(String url)
{
clearBrowserCookies();
open(Neodymium.configuration().url() + url);
return new ProductdetailPage();
return new ProductDetailPage().isExpectedPage();
}

@Step("open product page without cleared cookes")
public static ProductdetailPage openProductdetailsPage(String url)
public static ProductDetailPage openProductDetailsPage(String url)
{
open(Neodymium.configuration().url() + url);
return new ProductdetailPage();
return new ProductDetailPage().isExpectedPage();
}
}
Loading