From 187d429d76f38f0c63caf126b0292eca5f064a59 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Fri, 18 Dec 2020 21:40:38 +0100 Subject: [PATCH 01/11] Added: - more tests - page factory - explicit wait --- src/test/java/pageobjects/BasePage.java | 38 ++++++++++++-- src/test/java/pageobjects/HomePage.java | 5 +- src/test/java/pageobjects/LoginPage.java | 14 +++++- src/test/java/pageobjects/MyAccountPage.java | 4 -- src/test/java/pageobjects/ProductsPage.java | 49 +++++++++++++++++++ src/test/java/pageobjects/RegisterPage.java | 25 ++++++++++ .../java/pageobjects/SearchResultPage.java | 16 +++--- src/test/java/tests/BaseTest.java | 7 ++- src/test/java/tests/CartTest.java | 31 ++++++++++++ src/test/java/tests/LoginTest.java | 3 -- src/test/java/tests/RegisterTest.java | 22 +++++++++ src/test/java/tests/SearchTest.java | 10 ++-- src/test/java/utils/RandomUser.java | 41 ++++++++++++++++ 13 files changed, 240 insertions(+), 25 deletions(-) delete mode 100644 src/test/java/pageobjects/MyAccountPage.java create mode 100644 src/test/java/pageobjects/ProductsPage.java create mode 100644 src/test/java/pageobjects/RegisterPage.java create mode 100644 src/test/java/tests/CartTest.java create mode 100644 src/test/java/tests/RegisterTest.java create mode 100644 src/test/java/utils/RandomUser.java diff --git a/src/test/java/pageobjects/BasePage.java b/src/test/java/pageobjects/BasePage.java index c7b51f8..13eb067 100644 --- a/src/test/java/pageobjects/BasePage.java +++ b/src/test/java/pageobjects/BasePage.java @@ -1,17 +1,49 @@ package pageobjects; -import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.List; public class BasePage { + @FindBy(id="search_query_top") + WebElement searchBox; + + @FindBy(css = ".menu-content>li>a") + List productCategories; + + @FindBy(css = ".shopping_cart .ajax_cart_quantity") + WebElement cartQuantity; + WebDriver driver; + WebDriverWait wait; + static final String BASE_URL = "http://automationpractice.com/"; + public BasePage(WebDriver driverIn, WebDriverWait waitIn) { + this.driver = driverIn; + + this.wait = waitIn; + PageFactory.initElements(driver, this); + } + public void searchForProduct(String productName) { - driver.findElement(By.id("search_query_top")).sendKeys("dress"); - driver.findElement(By.id("search_query_top")).sendKeys(Keys.ENTER); + searchBox.sendKeys("dress"); + searchBox.sendKeys(Keys.ENTER); + } + + public void goToProductCategoryByIndex(int productCategoryIndex) { + productCategories.get(productCategoryIndex).click(); } + public int getCartSize() { + String cartQuantityText = cartQuantity.getText(); + return Integer.parseInt(cartQuantityText); + } } + diff --git a/src/test/java/pageobjects/HomePage.java b/src/test/java/pageobjects/HomePage.java index 95ac93f..dfdc8d1 100644 --- a/src/test/java/pageobjects/HomePage.java +++ b/src/test/java/pageobjects/HomePage.java @@ -1,11 +1,12 @@ package pageobjects; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.WebDriverWait; public class HomePage extends BasePage { - public HomePage(WebDriver driverIn) { - this.driver = driverIn; + public HomePage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); } public void openPage() { diff --git a/src/test/java/pageobjects/LoginPage.java b/src/test/java/pageobjects/LoginPage.java index ad09bf1..5af910f 100644 --- a/src/test/java/pageobjects/LoginPage.java +++ b/src/test/java/pageobjects/LoginPage.java @@ -1,4 +1,16 @@ package pageobjects; -public class LoginPage { +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class LoginPage extends BasePage { + + public LoginPage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); + } + + public void goToRegisterForm(String email) { + // wpisz email w pole CREATE AN ACCOUNT > email address + // wciśnij enter + } } diff --git a/src/test/java/pageobjects/MyAccountPage.java b/src/test/java/pageobjects/MyAccountPage.java deleted file mode 100644 index 93949fc..0000000 --- a/src/test/java/pageobjects/MyAccountPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package pageobjects; - -public class MyAccountPage { -} diff --git a/src/test/java/pageobjects/ProductsPage.java b/src/test/java/pageobjects/ProductsPage.java new file mode 100644 index 0000000..d456c6e --- /dev/null +++ b/src/test/java/pageobjects/ProductsPage.java @@ -0,0 +1,49 @@ +package pageobjects; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.List; +import java.util.Random; + +public class ProductsPage extends BasePage { + + @FindBy(css = ".product_list .product-container") + List productsContainers; + + @FindBy(css = ".ajax_add_to_cart_button") + List addToCartButtons; + + @FindBy(className = "continue") + WebElement continueShoppingButton; + + public ProductsPage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); + } + + public void moveMouseToProductContainer(int productIndex) { + Actions builder = new Actions(driver); + builder.moveToElement(productsContainers.get(productIndex)).build().perform(); + } + + public void addProductToTheBasket(int productIndex) { + wait.until(ExpectedConditions.elementToBeClickable(addToCartButtons.get(productIndex))); + addToCartButtons.get(productIndex).click(); + + wait.until(ExpectedConditions.elementToBeClickable(continueShoppingButton)); + continueShoppingButton.click(); + } + + public void addRandomProductToCart() { + Random rnd = new Random(); + int productIndex = rnd.nextInt(productsContainers.size()); + + moveMouseToProductContainer(productIndex); + + addProductToTheBasket(productIndex); + } +} diff --git a/src/test/java/pageobjects/RegisterPage.java b/src/test/java/pageobjects/RegisterPage.java new file mode 100644 index 0000000..8ce8620 --- /dev/null +++ b/src/test/java/pageobjects/RegisterPage.java @@ -0,0 +1,25 @@ +package pageobjects; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.ui.WebDriverWait; +import utils.RandomUser; + +public class RegisterPage extends BasePage{ + + @FindBy(id = "customer_firstname") + WebElement customerFirstName; + + @FindBy(id = "customer_lastname") + WebElement customerLastName; + + public RegisterPage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); + } + + public void registerUser(RandomUser user) { + customerFirstName.sendKeys(user.firstName); + customerLastName.sendKeys(user.lastName); + } +} diff --git a/src/test/java/pageobjects/SearchResultPage.java b/src/test/java/pageobjects/SearchResultPage.java index e7a128d..4f9736a 100644 --- a/src/test/java/pageobjects/SearchResultPage.java +++ b/src/test/java/pageobjects/SearchResultPage.java @@ -1,20 +1,25 @@ package pageobjects; -import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.ui.WebDriverWait; import java.util.List; public class SearchResultPage extends BasePage { - public SearchResultPage(WebDriver driverIn) { - this.driver = driverIn; + @FindBy(id = ".product_list .product-name") + List productsNames; + + @FindBy(css = ".heading-counter") + WebElement searchSummary; + + public SearchResultPage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); } public boolean isProductWithNameVisible(String expectedProductName) { - List productsNames = driver.findElements(By.cssSelector(".product_list .product-name")); - int counter = 0; for (WebElement productName : productsNames) { System.out.println(productName.getText()); if (productName.getText().toLowerCase().contains(expectedProductName.toLowerCase())) { @@ -25,7 +30,6 @@ public boolean isProductWithNameVisible(String expectedProductName) { } public String getSearchSummary() { - WebElement searchSummary = driver.findElement(By.cssSelector(".heading-counter")); return searchSummary.getText(); } } diff --git a/src/test/java/tests/BaseTest.java b/src/test/java/tests/BaseTest.java index ccc4e57..78c34fb 100644 --- a/src/test/java/tests/BaseTest.java +++ b/src/test/java/tests/BaseTest.java @@ -3,20 +3,23 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.openqa.selenium.Dimension; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.support.ui.WebDriverWait; import java.util.concurrent.TimeUnit; public class BaseTest { + static WebDriver driver; + static WebDriverWait wait; @BeforeAll static void setUp() { driver = new ChromeDriver(); + wait = new WebDriverWait(driver, 5); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); - driver.manage().window().setSize(new Dimension(1920, 1080)); + driver.manage().window().maximize(); } @BeforeEach diff --git a/src/test/java/tests/CartTest.java b/src/test/java/tests/CartTest.java new file mode 100644 index 0000000..ff5996a --- /dev/null +++ b/src/test/java/tests/CartTest.java @@ -0,0 +1,31 @@ +package tests; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import pageobjects.HomePage; +import pageobjects.ProductsPage; + +public class CartTest extends BaseTest { + + @Test + void shouldBeAbleAddProductToTheCart() { + ProductsPage productsPage = goToProductCategoryPage(0); + productsPage.addRandomProductToCart(); + Assertions.assertEquals(1, productsPage.getCartSize()); + } + + @Test + void shouldBeAbleAddMultipleProductsToTheCart() { + ProductsPage productsPage = goToProductCategoryPage(1); + productsPage.addRandomProductToCart(); + productsPage.addRandomProductToCart(); + Assertions.assertEquals(2, productsPage.getCartSize()); + } + + private ProductsPage goToProductCategoryPage(int i) { + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); + homePage.goToProductCategoryByIndex(0); + return new ProductsPage(driver, wait); + } +} diff --git a/src/test/java/tests/LoginTest.java b/src/test/java/tests/LoginTest.java index 754d97d..b1cb5b7 100644 --- a/src/test/java/tests/LoginTest.java +++ b/src/test/java/tests/LoginTest.java @@ -1,9 +1,6 @@ package tests; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.chrome.ChromeDriver; public class LoginTest { @Test diff --git a/src/test/java/tests/RegisterTest.java b/src/test/java/tests/RegisterTest.java new file mode 100644 index 0000000..208ac38 --- /dev/null +++ b/src/test/java/tests/RegisterTest.java @@ -0,0 +1,22 @@ +package tests; + +import org.junit.jupiter.api.Test; +import pageobjects.LoginPage; +import pageobjects.RegisterPage; +import utils.RandomUser; + +public class RegisterTest extends BaseTest { + + @Test + void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() { + + RandomUser user = new RandomUser(); + System.out.println(user); + + LoginPage loginPage = new LoginPage(driver, wait); + loginPage.goToRegisterForm(user.email); + + RegisterPage registerPage = new RegisterPage(driver, wait); + registerPage.registerUser(user); + } +} diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java index 3d47a81..87ad728 100644 --- a/src/test/java/tests/SearchTest.java +++ b/src/test/java/tests/SearchTest.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import pageobjects.HomePage; import pageobjects.SearchResultPage; @@ -11,12 +9,16 @@ public class SearchTest extends BaseTest { @Test void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { - HomePage homePage = new HomePage(driver); + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); + homePage.searchForProduct("dress"); - SearchResultPage searchResultPage = new SearchResultPage(driver); + SearchResultPage searchResultPage = new SearchResultPage(driver, wait); + Assertions.assertTrue(searchResultPage.isProductWithNameVisible("dress")); + Assertions.assertEquals("7 results have been found.", searchResultPage.getSearchSummary()); } } diff --git a/src/test/java/utils/RandomUser.java b/src/test/java/utils/RandomUser.java new file mode 100644 index 0000000..7537921 --- /dev/null +++ b/src/test/java/utils/RandomUser.java @@ -0,0 +1,41 @@ +package utils; + +import com.github.javafaker.Faker; +import org.w3c.dom.ls.LSOutput; + +public class RandomUser { + + public String firstName; + public String lastName; + public String email; + public String password; + public String address1; + public int zipCode; + public int dayOfBirth; + public int monthOfBirth; + public int yearOfBirth; + + public RandomUser() { + Faker faker = new Faker(); + firstName = faker.name().firstName(); + lastName = faker.name().lastName(); + yearOfBirth = faker.random().nextInt(1910, 2020); + email = firstName + lastName + yearOfBirth + "gmail.com"; + zipCode = faker.random().nextInt(10000, 99999); + } + + @Override + public String toString() { + return "RandomUser{" + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", email='" + email + '\'' + + ", password='" + password + '\'' + + ", address1='" + address1 + '\'' + + ", zipCode=" + zipCode + + ", dayOfBirth=" + dayOfBirth + + ", monthOfBirth=" + monthOfBirth + + ", yearOfBirth=" + yearOfBirth + + '}'; + } +} From 1068d3e3d389244489411ecb24a84f27cdba77de Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Fri, 18 Dec 2020 21:42:23 +0100 Subject: [PATCH 02/11] Added: - more tests - page factory - explicit wait --- src/test/java/tests/SearchTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java index 87ad728..a3ab97d 100644 --- a/src/test/java/tests/SearchTest.java +++ b/src/test/java/tests/SearchTest.java @@ -10,15 +10,11 @@ public class SearchTest extends BaseTest { @Test void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { HomePage homePage = new HomePage(driver, wait); - homePage.openPage(); - homePage.searchForProduct("dress"); SearchResultPage searchResultPage = new SearchResultPage(driver, wait); - Assertions.assertTrue(searchResultPage.isProductWithNameVisible("dress")); - Assertions.assertEquals("7 results have been found.", searchResultPage.getSearchSummary()); } } From 0148553cfc47ef167ed601827a22e4f7bf3fecb6 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Sat, 19 Dec 2020 09:16:51 +0100 Subject: [PATCH 03/11] Updated: - more tests - page factory - explicit wait - deleted comments - deleted spaces --- src/test/java/pageobjects/BasePage.java | 1 - src/test/java/pageobjects/HomePage.java | 1 - src/test/java/pageobjects/LoginPage.java | 1 - src/test/java/pageobjects/ProductsPage.java | 1 - src/test/java/pageobjects/RegisterPage.java | 1 - src/test/java/pageobjects/SearchResultPage.java | 1 - src/test/java/tests/BaseTest.java | 1 - src/test/java/tests/CartTest.java | 1 - src/test/java/tests/RegisterTest.java | 1 - src/test/java/tests/SearchTest.java | 2 +- src/test/java/utils/RandomUser.java | 1 - 11 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/test/java/pageobjects/BasePage.java b/src/test/java/pageobjects/BasePage.java index 13eb067..6f4acf8 100644 --- a/src/test/java/pageobjects/BasePage.java +++ b/src/test/java/pageobjects/BasePage.java @@ -10,7 +10,6 @@ import java.util.List; public class BasePage { - @FindBy(id="search_query_top") WebElement searchBox; diff --git a/src/test/java/pageobjects/HomePage.java b/src/test/java/pageobjects/HomePage.java index dfdc8d1..b8f55ff 100644 --- a/src/test/java/pageobjects/HomePage.java +++ b/src/test/java/pageobjects/HomePage.java @@ -4,7 +4,6 @@ import org.openqa.selenium.support.ui.WebDriverWait; public class HomePage extends BasePage { - public HomePage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } diff --git a/src/test/java/pageobjects/LoginPage.java b/src/test/java/pageobjects/LoginPage.java index 5af910f..31c3064 100644 --- a/src/test/java/pageobjects/LoginPage.java +++ b/src/test/java/pageobjects/LoginPage.java @@ -4,7 +4,6 @@ import org.openqa.selenium.support.ui.WebDriverWait; public class LoginPage extends BasePage { - public LoginPage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } diff --git a/src/test/java/pageobjects/ProductsPage.java b/src/test/java/pageobjects/ProductsPage.java index d456c6e..0ccaae8 100644 --- a/src/test/java/pageobjects/ProductsPage.java +++ b/src/test/java/pageobjects/ProductsPage.java @@ -11,7 +11,6 @@ import java.util.Random; public class ProductsPage extends BasePage { - @FindBy(css = ".product_list .product-container") List productsContainers; diff --git a/src/test/java/pageobjects/RegisterPage.java b/src/test/java/pageobjects/RegisterPage.java index 8ce8620..542f5d4 100644 --- a/src/test/java/pageobjects/RegisterPage.java +++ b/src/test/java/pageobjects/RegisterPage.java @@ -7,7 +7,6 @@ import utils.RandomUser; public class RegisterPage extends BasePage{ - @FindBy(id = "customer_firstname") WebElement customerFirstName; diff --git a/src/test/java/pageobjects/SearchResultPage.java b/src/test/java/pageobjects/SearchResultPage.java index 4f9736a..a1b208f 100644 --- a/src/test/java/pageobjects/SearchResultPage.java +++ b/src/test/java/pageobjects/SearchResultPage.java @@ -8,7 +8,6 @@ import java.util.List; public class SearchResultPage extends BasePage { - @FindBy(id = ".product_list .product-name") List productsNames; diff --git a/src/test/java/tests/BaseTest.java b/src/test/java/tests/BaseTest.java index 78c34fb..e4f1d92 100644 --- a/src/test/java/tests/BaseTest.java +++ b/src/test/java/tests/BaseTest.java @@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit; public class BaseTest { - static WebDriver driver; static WebDriverWait wait; diff --git a/src/test/java/tests/CartTest.java b/src/test/java/tests/CartTest.java index ff5996a..5f38e1c 100644 --- a/src/test/java/tests/CartTest.java +++ b/src/test/java/tests/CartTest.java @@ -6,7 +6,6 @@ import pageobjects.ProductsPage; public class CartTest extends BaseTest { - @Test void shouldBeAbleAddProductToTheCart() { ProductsPage productsPage = goToProductCategoryPage(0); diff --git a/src/test/java/tests/RegisterTest.java b/src/test/java/tests/RegisterTest.java index 208ac38..9db5bcc 100644 --- a/src/test/java/tests/RegisterTest.java +++ b/src/test/java/tests/RegisterTest.java @@ -6,7 +6,6 @@ import utils.RandomUser; public class RegisterTest extends BaseTest { - @Test void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() { diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java index a3ab97d..b57623f 100644 --- a/src/test/java/tests/SearchTest.java +++ b/src/test/java/tests/SearchTest.java @@ -6,9 +6,9 @@ import pageobjects.SearchResultPage; public class SearchTest extends BaseTest { - @Test void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { + HomePage homePage = new HomePage(driver, wait); homePage.openPage(); homePage.searchForProduct("dress"); diff --git a/src/test/java/utils/RandomUser.java b/src/test/java/utils/RandomUser.java index 7537921..53274cf 100644 --- a/src/test/java/utils/RandomUser.java +++ b/src/test/java/utils/RandomUser.java @@ -1,7 +1,6 @@ package utils; import com.github.javafaker.Faker; -import org.w3c.dom.ls.LSOutput; public class RandomUser { From c347b2d5ef5aa69f6401b9f1e47bbc74bd9ff5cb Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Sat, 19 Dec 2020 10:31:44 +0100 Subject: [PATCH 04/11] Updated: - deleted spaces --- src/test/java/pageobjects/BasePage.java | 1 + src/test/java/pageobjects/HomePage.java | 1 + src/test/java/pageobjects/LoginPage.java | 1 + src/test/java/pageobjects/ProductsPage.java | 1 + src/test/java/pageobjects/RegisterPage.java | 3 ++- src/test/java/pageobjects/SearchResultPage.java | 1 + src/test/java/tests/BaseTest.java | 1 + src/test/java/tests/CartTest.java | 1 + src/test/java/tests/LoginTest.java | 3 ++- src/test/java/tests/RegisterTest.java | 1 + src/test/java/tests/SearchTest.java | 1 + 11 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/java/pageobjects/BasePage.java b/src/test/java/pageobjects/BasePage.java index 6f4acf8..13eb067 100644 --- a/src/test/java/pageobjects/BasePage.java +++ b/src/test/java/pageobjects/BasePage.java @@ -10,6 +10,7 @@ import java.util.List; public class BasePage { + @FindBy(id="search_query_top") WebElement searchBox; diff --git a/src/test/java/pageobjects/HomePage.java b/src/test/java/pageobjects/HomePage.java index b8f55ff..dfdc8d1 100644 --- a/src/test/java/pageobjects/HomePage.java +++ b/src/test/java/pageobjects/HomePage.java @@ -4,6 +4,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; public class HomePage extends BasePage { + public HomePage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } diff --git a/src/test/java/pageobjects/LoginPage.java b/src/test/java/pageobjects/LoginPage.java index 31c3064..5af910f 100644 --- a/src/test/java/pageobjects/LoginPage.java +++ b/src/test/java/pageobjects/LoginPage.java @@ -4,6 +4,7 @@ import org.openqa.selenium.support.ui.WebDriverWait; public class LoginPage extends BasePage { + public LoginPage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } diff --git a/src/test/java/pageobjects/ProductsPage.java b/src/test/java/pageobjects/ProductsPage.java index 0ccaae8..d456c6e 100644 --- a/src/test/java/pageobjects/ProductsPage.java +++ b/src/test/java/pageobjects/ProductsPage.java @@ -11,6 +11,7 @@ import java.util.Random; public class ProductsPage extends BasePage { + @FindBy(css = ".product_list .product-container") List productsContainers; diff --git a/src/test/java/pageobjects/RegisterPage.java b/src/test/java/pageobjects/RegisterPage.java index 542f5d4..11c5d13 100644 --- a/src/test/java/pageobjects/RegisterPage.java +++ b/src/test/java/pageobjects/RegisterPage.java @@ -6,7 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import utils.RandomUser; -public class RegisterPage extends BasePage{ +public class RegisterPage extends BasePage { + @FindBy(id = "customer_firstname") WebElement customerFirstName; diff --git a/src/test/java/pageobjects/SearchResultPage.java b/src/test/java/pageobjects/SearchResultPage.java index a1b208f..4f9736a 100644 --- a/src/test/java/pageobjects/SearchResultPage.java +++ b/src/test/java/pageobjects/SearchResultPage.java @@ -8,6 +8,7 @@ import java.util.List; public class SearchResultPage extends BasePage { + @FindBy(id = ".product_list .product-name") List productsNames; diff --git a/src/test/java/tests/BaseTest.java b/src/test/java/tests/BaseTest.java index e4f1d92..78c34fb 100644 --- a/src/test/java/tests/BaseTest.java +++ b/src/test/java/tests/BaseTest.java @@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit; public class BaseTest { + static WebDriver driver; static WebDriverWait wait; diff --git a/src/test/java/tests/CartTest.java b/src/test/java/tests/CartTest.java index 5f38e1c..ff5996a 100644 --- a/src/test/java/tests/CartTest.java +++ b/src/test/java/tests/CartTest.java @@ -6,6 +6,7 @@ import pageobjects.ProductsPage; public class CartTest extends BaseTest { + @Test void shouldBeAbleAddProductToTheCart() { ProductsPage productsPage = goToProductCategoryPage(0); diff --git a/src/test/java/tests/LoginTest.java b/src/test/java/tests/LoginTest.java index b1cb5b7..0a0f8c6 100644 --- a/src/test/java/tests/LoginTest.java +++ b/src/test/java/tests/LoginTest.java @@ -2,7 +2,8 @@ import org.junit.jupiter.api.Test; -public class LoginTest { +public class LoginTest extends BaseTest { + @Test void shouldRedirectToMyAccountPageWhenCorrectCredentialsAreUsed() { // implementacja testu (korzystamy z LoginPage oraz MyAccountPage) diff --git a/src/test/java/tests/RegisterTest.java b/src/test/java/tests/RegisterTest.java index 9db5bcc..208ac38 100644 --- a/src/test/java/tests/RegisterTest.java +++ b/src/test/java/tests/RegisterTest.java @@ -6,6 +6,7 @@ import utils.RandomUser; public class RegisterTest extends BaseTest { + @Test void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() { diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java index b57623f..00227a7 100644 --- a/src/test/java/tests/SearchTest.java +++ b/src/test/java/tests/SearchTest.java @@ -6,6 +6,7 @@ import pageobjects.SearchResultPage; public class SearchTest extends BaseTest { + @Test void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { From dfe1392dee34056bb80fb6535395219b75a741cf Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Sat, 19 Dec 2020 11:57:47 +0100 Subject: [PATCH 05/11] Added: - MyHomePage, LogOutTest, NavigationMenuTest - comments to tests - some empty tests --- src/test/java/pageobjects/MyAccountPage.java | 4 ++++ src/test/java/tests/CartTest.java | 3 +++ src/test/java/tests/LogOutTest.java | 11 +++++++++++ src/test/java/tests/LoginTest.java | 9 ++++++++- src/test/java/tests/NavigationMenuTest.java | 4 ++++ src/test/java/tests/RegisterTest.java | 12 ++++++++++++ src/test/java/tests/SearchTest.java | 6 ++++++ 7 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/test/java/pageobjects/MyAccountPage.java create mode 100644 src/test/java/tests/LogOutTest.java create mode 100644 src/test/java/tests/NavigationMenuTest.java diff --git a/src/test/java/pageobjects/MyAccountPage.java b/src/test/java/pageobjects/MyAccountPage.java new file mode 100644 index 0000000..93949fc --- /dev/null +++ b/src/test/java/pageobjects/MyAccountPage.java @@ -0,0 +1,4 @@ +package pageobjects; + +public class MyAccountPage { +} diff --git a/src/test/java/tests/CartTest.java b/src/test/java/tests/CartTest.java index ff5996a..531f489 100644 --- a/src/test/java/tests/CartTest.java +++ b/src/test/java/tests/CartTest.java @@ -9,6 +9,7 @@ public class CartTest extends BaseTest { @Test void shouldBeAbleAddProductToTheCart() { + // powinien być w stanie dodać produkt do koszyka ProductsPage productsPage = goToProductCategoryPage(0); productsPage.addRandomProductToCart(); Assertions.assertEquals(1, productsPage.getCartSize()); @@ -16,6 +17,7 @@ void shouldBeAbleAddProductToTheCart() { @Test void shouldBeAbleAddMultipleProductsToTheCart() { + // powinien być w stanie dodać wiele produktów do koszyka ProductsPage productsPage = goToProductCategoryPage(1); productsPage.addRandomProductToCart(); productsPage.addRandomProductToCart(); @@ -23,6 +25,7 @@ void shouldBeAbleAddMultipleProductsToTheCart() { } private ProductsPage goToProductCategoryPage(int i) { + // przejdź do strony kategorii produktów HomePage homePage = new HomePage(driver, wait); homePage.openPage(); homePage.goToProductCategoryByIndex(0); diff --git a/src/test/java/tests/LogOutTest.java b/src/test/java/tests/LogOutTest.java new file mode 100644 index 0000000..ba73b26 --- /dev/null +++ b/src/test/java/tests/LogOutTest.java @@ -0,0 +1,11 @@ +package tests; + +import org.junit.jupiter.api.Test; + +public class LogOutTest extends BaseTest { + + @Test + void shouldRedirectToTheLoginPageAfterLoggingOutOfMyAccount() { + // powinien przekierować na stronę logowania po wylogowaniu się z mojego konta + } +} diff --git a/src/test/java/tests/LoginTest.java b/src/test/java/tests/LoginTest.java index 0a0f8c6..986e0b5 100644 --- a/src/test/java/tests/LoginTest.java +++ b/src/test/java/tests/LoginTest.java @@ -6,6 +6,13 @@ public class LoginTest extends BaseTest { @Test void shouldRedirectToMyAccountPageWhenCorrectCredentialsAreUsed() { - // implementacja testu (korzystamy z LoginPage oraz MyAccountPage) + // powinno przekierować do strony Moje konto kiedy używane są prawidłowe poświadczenia + // implementacja testu (korzystamy z LoginPage oraz z MyAccountPage) + } + + @Test + void shouldRedirectToTheReLoginPageWhenCredentialsAreNotUsed() { + // powinien przekierować do ponownego logowania strony, kiedy poświadczenia nie są używane + // implementacja testu (korzystamy z LoginPage oraz z MyAccountPage) } } diff --git a/src/test/java/tests/NavigationMenuTest.java b/src/test/java/tests/NavigationMenuTest.java new file mode 100644 index 0000000..40565aa --- /dev/null +++ b/src/test/java/tests/NavigationMenuTest.java @@ -0,0 +1,4 @@ +package tests; + +public class NavigationMenuTest { +} diff --git a/src/test/java/tests/RegisterTest.java b/src/test/java/tests/RegisterTest.java index 208ac38..79338cd 100644 --- a/src/test/java/tests/RegisterTest.java +++ b/src/test/java/tests/RegisterTest.java @@ -19,4 +19,16 @@ void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() { RegisterPage registerPage = new RegisterPage(driver, wait); registerPage.registerUser(user); } + + @Test + void shouldNoRegisterNewUserWhenNotAllMandatoryDataIsProvided() { + // nie należy rejestrować nowego użytkownika, gdy nie podano wszystkich obowiązkowych danych + // implementacja testu (korzystamy z imilementacji RandomUser, z LoginPage oraz z RegisterPage) + } + + @Test + void shouldNoRegisterNewUserWhenIncorrectValueOfMandatoryDataIsProvided() { + // nie należy rejestrować nowego użytkownika w przypadku podania nieprawidłowej wartości obowiązkowych danych + // implementacja testu (korzystamy z implementacji RandomUser, z LoginPage oraz z RegisterPage) + } } diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java index 00227a7..4d5df9c 100644 --- a/src/test/java/tests/SearchTest.java +++ b/src/test/java/tests/SearchTest.java @@ -9,6 +9,7 @@ public class SearchTest extends BaseTest { @Test void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { + // powinien zwrócić poprawną listę produktów, gdy użyto pozytywnej frazy wyszukiwania HomePage homePage = new HomePage(driver, wait); homePage.openPage(); @@ -18,4 +19,9 @@ void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { Assertions.assertTrue(searchResultPage.isProductWithNameVisible("dress")); Assertions.assertEquals("7 results have been found.", searchResultPage.getSearchSummary()); } + + @Test + void shouldNotReturnCorrectProductListWhenNegativeSearchPhraseIsUsed() { + // nie powinien zwracać prawidłowej listy produktów, gdy używana jest wykluczająca fraza wyszukiwania + } } From 564eddd6596ff058b1880b1657a109aed9cf6d98 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev <74302800+MrPenguin-dev@users.noreply.github.com> Date: Thu, 24 Dec 2020 19:04:21 +0100 Subject: [PATCH 06/11] Delete MyAccountPage file --- src/test/java/pageobjects/MyAccountPage.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/test/java/pageobjects/MyAccountPage.java diff --git a/src/test/java/pageobjects/MyAccountPage.java b/src/test/java/pageobjects/MyAccountPage.java deleted file mode 100644 index 93949fc..0000000 --- a/src/test/java/pageobjects/MyAccountPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package pageobjects; - -public class MyAccountPage { -} From 3f44a1d9ceea52b2f5d491293cfbc9a36bc1d47d Mon Sep 17 00:00:00 2001 From: Nikita Rysiev <74302800+MrPenguin-dev@users.noreply.github.com> Date: Thu, 24 Dec 2020 19:10:49 +0100 Subject: [PATCH 07/11] Deleted NavigationMenuTest --- src/test/java/tests/NavigationMenuTest.java | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/test/java/tests/NavigationMenuTest.java diff --git a/src/test/java/tests/NavigationMenuTest.java b/src/test/java/tests/NavigationMenuTest.java deleted file mode 100644 index 40565aa..0000000 --- a/src/test/java/tests/NavigationMenuTest.java +++ /dev/null @@ -1,4 +0,0 @@ -package tests; - -public class NavigationMenuTest { -} From cefd985852b51f58550a2479d75be428f202b668 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev <74302800+MrPenguin-dev@users.noreply.github.com> Date: Thu, 24 Dec 2020 19:11:14 +0100 Subject: [PATCH 08/11] Deleted LogOutTest --- src/test/java/tests/LogOutTest.java | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/test/java/tests/LogOutTest.java diff --git a/src/test/java/tests/LogOutTest.java b/src/test/java/tests/LogOutTest.java deleted file mode 100644 index ba73b26..0000000 --- a/src/test/java/tests/LogOutTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Test; - -public class LogOutTest extends BaseTest { - - @Test - void shouldRedirectToTheLoginPageAfterLoggingOutOfMyAccount() { - // powinien przekierować na stronę logowania po wylogowaniu się z mojego konta - } -} From 9371957634c01f5981f81d4707c8beb8e9d3bd25 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev <74302800+MrPenguin-dev@users.noreply.github.com> Date: Thu, 24 Dec 2020 19:25:03 +0100 Subject: [PATCH 09/11] Updated README.md --- README.md | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 39af52c..46628ef 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,23 @@ -# README # - -This README would normally document whatever steps are necessary to get your application up and running. - -### What is this repository for? ### - -* Quick summary -* Version -* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo) - -### How do I get set up? ### - -* Summary of set up -* Configuration -* Dependencies -* Database configuration -* How to run tests -* Deployment instructions - -### Contribution guidelines ### - -* Writing tests -* Code review -* Other guidelines - -### Who do I talk to? ### - -* Repo owner or admin -* Other community or team contact \ No newline at end of file +# Manual-Tester-Auto-Test +## Used: +1. Java 11+ +2. Maven +3. Selenium WebDriver +4. jUnit 5.x +5. Page object pattern +6. Page factory + +### for page: +[Automationpractice](http://automationpractice.com ) + +## Added: + +| to pageobjects: | to tests: | to utils: | +| --------------------- |:---------------------:|-----------:| +| BasePage | BaseTest | RandomUser | +| HomePage | CartTest | | +| LoginPage | LoginTest | | +| ExecutionOfOrdersPage | ExecutionOfOrdersTest | | +| ProductsPage | RegisterTest | | +| RegisterPage | SearchTest | | +| SearchResultPage | | | From b764b85665da3aef0789d1a7b59550a61753223e Mon Sep 17 00:00:00 2001 From: Nikita Rysiev Date: Thu, 24 Dec 2020 19:39:04 +0100 Subject: [PATCH 10/11] Added: - ExecutionOfOrdersPage/Tests - more comments to tests Updated: - BasePage / - BaseTests - HomePage - LoginPage / - LoginTests - ExecutionOfOrdersPage / - ExecutionOfOrdersTests - ProductsPage - RegisterPage / - RegisterTests - SearchResultPage / - SearchResultTests - CartTests - RandomUser --- src/test/java/pageobjects/BasePage.java | 40 +++++++--- .../pageobjects/ExecutionOfOrdersPage.java | 40 ++++++++++ src/test/java/pageobjects/HomePage.java | 16 ++-- src/test/java/pageobjects/LoginPage.java | 53 ++++++++++++- src/test/java/pageobjects/MyAccountPage.java | 4 - src/test/java/pageobjects/ProductsPage.java | 45 ++++++++--- src/test/java/pageobjects/RegisterPage.java | 79 ++++++++++++++++++- .../java/pageobjects/SearchResultPage.java | 19 +++-- src/test/java/tests/BaseTest.java | 35 -------- src/test/java/tests/BaseTests.java | 43 ++++++++++ src/test/java/tests/CartTest.java | 34 -------- src/test/java/tests/CartTests.java | 35 ++++++++ .../java/tests/ExecutionOfOrdersTests.java | 26 ++++++ src/test/java/tests/LogOutTest.java | 11 --- src/test/java/tests/LoginTest.java | 18 ----- src/test/java/tests/LoginTests.java | 36 +++++++++ src/test/java/tests/NavigationMenuTest.java | 4 - src/test/java/tests/RegisterTest.java | 34 -------- src/test/java/tests/RegisterTests.java | 24 ++++++ src/test/java/tests/SearchResultTests.java | 24 ++++++ src/test/java/tests/SearchTest.java | 27 ------- src/test/java/utils/RandomUser.java | 28 ++++++- 22 files changed, 460 insertions(+), 215 deletions(-) create mode 100644 src/test/java/pageobjects/ExecutionOfOrdersPage.java delete mode 100644 src/test/java/pageobjects/MyAccountPage.java delete mode 100644 src/test/java/tests/BaseTest.java create mode 100644 src/test/java/tests/BaseTests.java delete mode 100644 src/test/java/tests/CartTest.java create mode 100644 src/test/java/tests/CartTests.java create mode 100644 src/test/java/tests/ExecutionOfOrdersTests.java delete mode 100644 src/test/java/tests/LogOutTest.java delete mode 100644 src/test/java/tests/LoginTest.java create mode 100644 src/test/java/tests/LoginTests.java delete mode 100644 src/test/java/tests/NavigationMenuTest.java delete mode 100644 src/test/java/tests/RegisterTest.java create mode 100644 src/test/java/tests/RegisterTests.java create mode 100644 src/test/java/tests/SearchResultTests.java delete mode 100644 src/test/java/tests/SearchTest.java diff --git a/src/test/java/pageobjects/BasePage.java b/src/test/java/pageobjects/BasePage.java index 13eb067..cb44ae3 100644 --- a/src/test/java/pageobjects/BasePage.java +++ b/src/test/java/pageobjects/BasePage.java @@ -9,41 +9,55 @@ import java.util.List; -public class BasePage { +// here we put selectors and methods common to all subpages of our test application +// we do that we can see in automationpractice.com that footer and headers are the same on all subpages - @FindBy(id="search_query_top") - WebElement searchBox; +public class BasePage { + // @FindBy to Page Factory and expands Page Object + @FindBy(id="search_query_top") // it's the same as driver.findElement(By.id("search_query_top")) + WebElement searchBox; // it's the same as driver.findElement(By.id("search_query_top")) @FindBy(css = ".menu-content>li>a") - List productCategories; + List productCategories; // List productCategories = driver.findElements (By.cssSelector (". Menu-content> li> a")); @FindBy(css = ".shopping_cart .ajax_cart_quantity") WebElement cartQuantity; - WebDriver driver; + @FindBy(className = "login") + WebElement signInButton; + + WebDriver driver; // because our diver is here so every other class inherits this driver WebDriverWait wait; static final String BASE_URL = "http://automationpractice.com/"; - public BasePage(WebDriver driverIn, WebDriverWait waitIn) { - this.driver = driverIn; - + public BasePage(WebDriver driverIn, WebDriverWait waitIn) { // we need create constructor to give 'static' WebDriver diver;' from tests / java / tests / BaseTests + this.driver = driverIn; // driverIn is driver with comes from our method executed this.wait = waitIn; + // we must say in constructor that InteliJ IDEA should initialize and find elements @FindBy PageFactory.initElements(driver, this); } public void searchForProduct(String productName) { - searchBox.sendKeys("dress"); - searchBox.sendKeys(Keys.ENTER); + // write searching keyword in search box and enter + searchBox.sendKeys("dress"); // in search pool we type dress + searchBox.sendKeys(Keys.ENTER); // confirm searching phrase with enter } - public void goToProductCategoryByIndex(int productCategoryIndex) { - productCategories.get(productCategoryIndex).click(); + // Menu: WOMEN | DRESSES | T-SHIRTS is available in all subpages we can put method + // opening selected category in our BasePage class: + public void goToProductCategoryByIndex(int productCategoryIndex) { // depending with we choose (WOMEN, DRESSES, T-SHIRTS) method will click on this what we choose + // we created locator to three elements on menu bar in @FindBy + productCategories.get(productCategoryIndex).click(); // we click on forwarded "productCategoryIndex" in menu } public int getCartSize() { String cartQuantityText = cartQuantity.getText(); return Integer.parseInt(cartQuantityText); } -} + public void clickSignIn() { + signInButton.click(); + } + +} diff --git a/src/test/java/pageobjects/ExecutionOfOrdersPage.java b/src/test/java/pageobjects/ExecutionOfOrdersPage.java new file mode 100644 index 0000000..71c5d2a --- /dev/null +++ b/src/test/java/pageobjects/ExecutionOfOrdersPage.java @@ -0,0 +1,40 @@ +package pageobjects; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.How; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class ExecutionOfOrdersPage extends BasePage { + @FindBy(how = How.NAME, using = "processAddress") + WebElement proceedToCheckout; + + @FindBy(id = "uniform-cgv") + WebElement termsOfServiceCheckBox; + + @FindBy(how = How.NAME, using = "processCarrier") + WebElement proceedToCheckoutAgain; + + @FindBy(className = "bankwire") + WebElement payByBankWireButton; + + @FindBy(className = "cheque") + WebElement payByCheckButton; + + @FindBy(xpath = "//button[@type='submit' and contains(.,'confirm ' )]") + WebElement confirmMyOrderButton; + + public ExecutionOfOrdersPage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); + } + + public void completionOfTheOrder() { + proceedToCheckout.click(); + termsOfServiceCheckBox.click(); + proceedToCheckoutAgain.click(); + payByBankWireButton.click(); + confirmMyOrderButton.click(); + } + +} \ No newline at end of file diff --git a/src/test/java/pageobjects/HomePage.java b/src/test/java/pageobjects/HomePage.java index dfdc8d1..d3f4a07 100644 --- a/src/test/java/pageobjects/HomePage.java +++ b/src/test/java/pageobjects/HomePage.java @@ -4,13 +4,13 @@ import org.openqa.selenium.support.ui.WebDriverWait; public class HomePage extends BasePage { + public HomePage(WebDriver driverIn, WebDriverWait waitIn) { + super(driverIn, waitIn); + } - public HomePage(WebDriver driverIn, WebDriverWait waitIn) { - super(driverIn, waitIn); - } + // open main page + public void openPage() { + driver.get(BASE_URL + "index.php"); + } - public void openPage() { - driver.get(BASE_URL + "index.php"); - } - -} +} \ No newline at end of file diff --git a/src/test/java/pageobjects/LoginPage.java b/src/test/java/pageobjects/LoginPage.java index 5af910f..93ee43c 100644 --- a/src/test/java/pageobjects/LoginPage.java +++ b/src/test/java/pageobjects/LoginPage.java @@ -1,16 +1,61 @@ package pageobjects; +import org.junit.jupiter.api.Assertions; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.WebDriverWait; +import utils.RandomUser; public class LoginPage extends BasePage { + @FindBy(id = "email") + WebElement emailAddressField; + + @FindBy(id = "passwd") + WebElement passwdField; + + @FindBy(id = "SubmitLogin") + WebElement signInButton; + + @FindBy(className = "logout") + WebElement signOutButton; + + @FindBy(id = "email_create") + WebElement createNewAccountField; + + @FindBy(id = "SubmitCreate") + WebElement createNewAccountButton; public LoginPage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } - public void goToRegisterForm(String email) { - // wpisz email w pole CREATE AN ACCOUNT > email address - // wciśnij enter + public void goToRegisterForm() throws InterruptedException { + RandomUser user = new RandomUser(); + clickSignIn(); + createNewAccountField.sendKeys(user.email); + createNewAccountButton.click(); + } + + public void signInToRegisteredAccount() { + emailAddressField.sendKeys("test@autotest.pl"); // registered + passwdField.sendKeys("autoTest_1234!"); // registered + signInButton.click(); + Assertions.assertEquals(signOutButton.getText(), "Sign out"); + } + + public void signInToNotRegisteredAccount() { + RandomUser user = new RandomUser(); + emailAddressField.sendKeys(user.email); // not registered + passwdField.sendKeys(user.password); // not registered + signInButton.click(); + // Assertions.assertEquals } -} + + public void continueOrderShouldAddProductToTheBasketAndBuyThroughRegisterForm() { + RandomUser user = new RandomUser(); + createNewAccountField.sendKeys(user.email); + createNewAccountButton.click(); + } + +} \ No newline at end of file diff --git a/src/test/java/pageobjects/MyAccountPage.java b/src/test/java/pageobjects/MyAccountPage.java deleted file mode 100644 index 93949fc..0000000 --- a/src/test/java/pageobjects/MyAccountPage.java +++ /dev/null @@ -1,4 +0,0 @@ -package pageobjects; - -public class MyAccountPage { -} diff --git a/src/test/java/pageobjects/ProductsPage.java b/src/test/java/pageobjects/ProductsPage.java index d456c6e..1d7e25b 100644 --- a/src/test/java/pageobjects/ProductsPage.java +++ b/src/test/java/pageobjects/ProductsPage.java @@ -11,7 +11,6 @@ import java.util.Random; public class ProductsPage extends BasePage { - @FindBy(css = ".product_list .product-container") List productsContainers; @@ -21,29 +20,55 @@ public class ProductsPage extends BasePage { @FindBy(className = "continue") WebElement continueShoppingButton; + @FindBy(linkText = "Proceed to checkout") + WebElement proceedCheckoutButton; + + // we need create constructor to give 'static WebDriver driver;' from src/test/java/tests/BaseTest public ProductsPage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } - public void moveMouseToProductContainer(int productIndex) { + public void moveMouseToProductContainer(int productIndex) { // List productsContainers = diver.findElements(By.cssSelector(".product_list .product-container")); Actions builder = new Actions(driver); - builder.moveToElement(productsContainers.get(productIndex)).build().perform(); + builder.moveToElement(productsContainers.get(productIndex)).build().perform(); // we must add ".build().perform();" every invoke moveToElement } public void addProductToTheBasket(int productIndex) { + // wait until element: "addToCartButtons.get(productIndex)" will be clickable wait.until(ExpectedConditions.elementToBeClickable(addToCartButtons.get(productIndex))); + // if is clickable > click addToCartButtons.get(productIndex).click(); - + // wait until element: "continueShoppingButton" will be clickable wait.until(ExpectedConditions.elementToBeClickable(continueShoppingButton)); + // if is clickable > click continueShoppingButton.click(); } - public void addRandomProductToCart() { - Random rnd = new Random(); - int productIndex = rnd.nextInt(productsContainers.size()); + public void addProductToTheBasketAndProceedCheckout(int productIndex) { + // wait until element: "addToCartButtons.get(productIndex)" will be clickable + wait.until(ExpectedConditions.elementToBeClickable(addToCartButtons.get(productIndex))); + // if is clickable > click + addToCartButtons.get(productIndex).click(); + // wait until element: "proceedCheckoutButton" will be clickable + wait.until(ExpectedConditions.elementToBeClickable(proceedCheckoutButton)); + // if is clickable > click + proceedCheckoutButton.click(); + // now we see summary and we must click proceedCheckoutButton again to continue shopping + proceedCheckoutButton.click(); + // now we are on LoginPage and we are ask to CREATE AN ACCOUNT or login by ALREADY REGISTERED? form + } - moveMouseToProductContainer(productIndex); + public void addRandomProductToCart() { + Random random = new Random(); + int productIndex = random.nextInt(productsContainers.size()); // set random number of product from showed product list + moveMouseToProductContainer(productIndex); // we except that sixth element from the list will be clicked // 5 + addProductToTheBasket(productIndex); // we click on sixth element to add to the basket // 5 + } - addProductToTheBasket(productIndex); + public void addRandomProductToCartAndProceedCheckout() { + Random random = new Random(); + int productIndex = random.nextInt(productsContainers.size()); // set random number of product from showed product list + moveMouseToProductContainer(productIndex); // we except that sixth element from the list will be clicked // 5 + addProductToTheBasketAndProceedCheckout(productIndex); // we click on sixth element to add to the basket // 5 } -} +} \ No newline at end of file diff --git a/src/test/java/pageobjects/RegisterPage.java b/src/test/java/pageobjects/RegisterPage.java index 11c5d13..9defe1d 100644 --- a/src/test/java/pageobjects/RegisterPage.java +++ b/src/test/java/pageobjects/RegisterPage.java @@ -1,25 +1,98 @@ package pageobjects; +import org.junit.jupiter.api.Assertions; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.WebDriverWait; import utils.RandomUser; -public class RegisterPage extends BasePage { +import java.util.List; +import java.util.Random; +public class RegisterPage extends BasePage { @FindBy(id = "customer_firstname") WebElement customerFirstName; @FindBy(id = "customer_lastname") WebElement customerLastName; + @FindBy(id = "id_gender1") + WebElement customerGender1; + + @FindBy(id = "id_gender2") + WebElement customerGender2; + + @FindBy(id = "passwd") + WebElement password; + + @FindBy(id = "days") + WebElement daysSelect; + Select selectDays = new Select(daysSelect); + + @FindBy(id = "month") + WebElement monthsSelect; + Select selectMonths = new Select(monthsSelect); + + @FindBy(id = "years") + WebElement yearsSelect; + Select selectYears = new Select(yearsSelect); + + @FindBy(id = "address1") + WebElement customerAddress; + + @FindBy(id = "city") + WebElement customerCity; + + @FindBy(id = "id_state") + WebElement customerStateSelect; + Select stateSelect = new Select(customerStateSelect); + + @FindBy(id ="postcode") + WebElement postCode; + + @FindBy(id = "phone_mobile") + WebElement customerPhoneMobile; + + @FindBy(id = "alias") + WebElement customerAlias; + + @FindBy(id = "submitAccount") + WebElement submitAccountButton; + + @FindBy(id = "logout") + WebElement signOutButton; + public RegisterPage(WebDriver driverIn, WebDriverWait waitIn) { super(driverIn, waitIn); } - public void registerUser(RandomUser user) { + public void registerUser(RandomUser user) throws InterruptedException { + RandomGender(); customerFirstName.sendKeys(user.firstName); customerLastName.sendKeys(user.lastName); + password.sendKeys(user.password); + selectDays.selectByIndex(1); + selectMonths.selectByIndex(1); + selectYears.selectByIndex(1); + customerAddress.sendKeys(user.address1); + customerCity.sendKeys(user.city); // we don't have city generator in faker so we type anything + stateSelect.selectByIndex(1); + postCode.sendKeys(user.zipCode); + customerPhoneMobile.sendKeys(user.phoneNumber); + customerAlias.sendKeys(user.firstName); + submitAccountButton.click(); + Assertions.assertEquals(signOutButton.getText(), "Sign out"); + } + + private void RandomGender() { + Random random = new Random(); + int gender = random.nextInt(2); + if (gender == 0) { + customerGender1.click(); + } else { + customerGender2.click(); + } } -} +} \ No newline at end of file diff --git a/src/test/java/pageobjects/SearchResultPage.java b/src/test/java/pageobjects/SearchResultPage.java index 4f9736a..32621a2 100644 --- a/src/test/java/pageobjects/SearchResultPage.java +++ b/src/test/java/pageobjects/SearchResultPage.java @@ -8,7 +8,6 @@ import java.util.List; public class SearchResultPage extends BasePage { - @FindBy(id = ".product_list .product-name") List productsNames; @@ -20,16 +19,24 @@ public SearchResultPage(WebDriver driverIn, WebDriverWait waitIn) { } public boolean isProductWithNameVisible(String expectedProductName) { + // findElements return List of elements so we must create variable to use found elements after in our code. cssSelector(String) + // List productsNames = driver.findElements(By.cssSelector(".product_list .product-name")); + + // Now we must create method to check every find element if it have 'expectedProductName'. We use foreach loop: + // First we tell what is kind of element (WebElement), next give him a name (productName), and in with collection are these productsName ? (productsNames) + for (WebElement productName : productsNames) { - System.out.println(productName.getText()); + System.out.println(productName.getText()); // in console view we type what is find if (productName.getText().toLowerCase().contains(expectedProductName.toLowerCase())) { - return true; + return true; // if is return true } } - return false; + return false; // when loop end find nothing } public String getSearchSummary() { - return searchSummary.getText(); + // WebElement searchSummary = driver.findElement(By.cssSelector(".heading-counter")); + + return searchSummary.getText(); // we must return text we found } -} +} \ No newline at end of file diff --git a/src/test/java/tests/BaseTest.java b/src/test/java/tests/BaseTest.java deleted file mode 100644 index 78c34fb..0000000 --- a/src/test/java/tests/BaseTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package tests; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.support.ui.WebDriverWait; - -import java.util.concurrent.TimeUnit; - -public class BaseTest { - - static WebDriver driver; - static WebDriverWait wait; - - @BeforeAll - static void setUp() { - driver = new ChromeDriver(); - wait = new WebDriverWait(driver, 5); - driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); - driver.manage().window().maximize(); - } - - @BeforeEach - void clearCookies() { - driver.manage().deleteAllCookies(); - } - - @AfterAll - static void tearDown() { - driver.quit(); // close all browser tabs/windows and webdriver - } - -} diff --git a/src/test/java/tests/BaseTests.java b/src/test/java/tests/BaseTests.java new file mode 100644 index 0000000..d4b9318 --- /dev/null +++ b/src/test/java/tests/BaseTests.java @@ -0,0 +1,43 @@ +/* This class contains methods: + - @BeforeAll - initialization WebDriver + - @BeforeEach - cleaning of cookies files + - @AfterAll - closing WebDriver */ + +package tests; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.util.concurrent.TimeUnit; + +public class BaseTests { + static WebDriver driver; + static WebDriverWait wait; + + @BeforeAll + static void setUp() { + // WebDriver drives a browser natively, like a user would be do it + driver = new ChromeDriver(); + wait = new WebDriverWait(driver, 5); + // we must set timeouts because without this our tests will fail + // Implicit wait: before every calling 'find element by..' we will wait 5 seconds to load all elements on the page + driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + // we need to open the page in full screen because if the page is responsive it looks different with different screen sizes + driver.manage().window().maximize(); // setSize.(new Dimension(1920, 1080)); // we open in full HD resolution + } + + @BeforeEach + void clearCookies() { + driver.manage().deleteAllCookies(); + } + + @AfterAll + static void tearDown() { + driver.quit(); // close all browser tabs/windows and webdriver + } + +} \ No newline at end of file diff --git a/src/test/java/tests/CartTest.java b/src/test/java/tests/CartTest.java deleted file mode 100644 index 531f489..0000000 --- a/src/test/java/tests/CartTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pageobjects.HomePage; -import pageobjects.ProductsPage; - -public class CartTest extends BaseTest { - - @Test - void shouldBeAbleAddProductToTheCart() { - // powinien być w stanie dodać produkt do koszyka - ProductsPage productsPage = goToProductCategoryPage(0); - productsPage.addRandomProductToCart(); - Assertions.assertEquals(1, productsPage.getCartSize()); - } - - @Test - void shouldBeAbleAddMultipleProductsToTheCart() { - // powinien być w stanie dodać wiele produktów do koszyka - ProductsPage productsPage = goToProductCategoryPage(1); - productsPage.addRandomProductToCart(); - productsPage.addRandomProductToCart(); - Assertions.assertEquals(2, productsPage.getCartSize()); - } - - private ProductsPage goToProductCategoryPage(int i) { - // przejdź do strony kategorii produktów - HomePage homePage = new HomePage(driver, wait); - homePage.openPage(); - homePage.goToProductCategoryByIndex(0); - return new ProductsPage(driver, wait); - } -} diff --git a/src/test/java/tests/CartTests.java b/src/test/java/tests/CartTests.java new file mode 100644 index 0000000..7131aae --- /dev/null +++ b/src/test/java/tests/CartTests.java @@ -0,0 +1,35 @@ +package tests; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import pageobjects.HomePage; +import pageobjects.ProductsPage; + +public class CartTests extends BaseTests { + @Test + void shouldBeAbleAddProductToTheCart() { + // create a Product page using the "goToProductCategoryPage()" method through which we go to any page + ProductsPage productsPage = goToProductCategoryPage(0); // it's a result of goToProductCategoryPage(); method + productsPage.addRandomProductToCart(); // order random product + // Assertions.assertTrue(product in the basket); + Assertions.assertEquals(1, productsPage.getCartSize()); // check if we have one product in the basket. Get how many products is in the basket and check if there is as many as we excepted (1) + } + + @Test + void shouldBeAbleAddMultipleProductsToTheCart() { + ProductsPage productsPage = goToProductCategoryPage(1); + productsPage.addRandomProductToCart(); + productsPage.addRandomProductToCart(); + Assertions.assertEquals(2, productsPage.getCartSize()); + } + + private ProductsPage goToProductCategoryPage(int i) { + HomePage homePage = new HomePage(driver, wait); // we sent to this Page Object class driver and wait + homePage.openPage(); // Open main Page + // on homepage we click on first element '0' from the menu list "productCategories" (WOMEN, DRESSES, T-SHIRTS) + homePage.goToProductCategoryByIndex(0); // go to MENU > WOMEN + // Then we want to simulate mouse move on products from the showed list on the page + ProductsPage productsPage = new ProductsPage(driver, wait); + return productsPage; + } +} \ No newline at end of file diff --git a/src/test/java/tests/ExecutionOfOrdersTests.java b/src/test/java/tests/ExecutionOfOrdersTests.java new file mode 100644 index 0000000..6c4bf00 --- /dev/null +++ b/src/test/java/tests/ExecutionOfOrdersTests.java @@ -0,0 +1,26 @@ +package tests; + +import org.junit.jupiter.api.Test; +import pageobjects.*; +import utils.RandomUser; + +public class ExecutionOfOrdersTests extends BaseTests { + @Test + void shouldAddProductToTheBasketAndBuyThroughRegisterForm() throws InterruptedException { + RandomUser user = new RandomUser(); + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); + ProductsPage productsPage = new ProductsPage(driver, wait); + productsPage.addRandomProductToCartAndProceedCheckout(); + + LoginPage loginPage = new LoginPage(driver, wait); + + loginPage.continueOrderShouldAddProductToTheBasketAndBuyThroughRegisterForm(); + + RegisterPage registerPage = new RegisterPage(driver, wait); + registerPage.registerUser(user); + + ExecutionOfOrdersPage executionOfOrdersPage = new ExecutionOfOrdersPage(driver, wait); + executionOfOrdersPage.completionOfTheOrder(); + } +} \ No newline at end of file diff --git a/src/test/java/tests/LogOutTest.java b/src/test/java/tests/LogOutTest.java deleted file mode 100644 index ba73b26..0000000 --- a/src/test/java/tests/LogOutTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Test; - -public class LogOutTest extends BaseTest { - - @Test - void shouldRedirectToTheLoginPageAfterLoggingOutOfMyAccount() { - // powinien przekierować na stronę logowania po wylogowaniu się z mojego konta - } -} diff --git a/src/test/java/tests/LoginTest.java b/src/test/java/tests/LoginTest.java deleted file mode 100644 index 986e0b5..0000000 --- a/src/test/java/tests/LoginTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Test; - -public class LoginTest extends BaseTest { - - @Test - void shouldRedirectToMyAccountPageWhenCorrectCredentialsAreUsed() { - // powinno przekierować do strony Moje konto kiedy używane są prawidłowe poświadczenia - // implementacja testu (korzystamy z LoginPage oraz z MyAccountPage) - } - - @Test - void shouldRedirectToTheReLoginPageWhenCredentialsAreNotUsed() { - // powinien przekierować do ponownego logowania strony, kiedy poświadczenia nie są używane - // implementacja testu (korzystamy z LoginPage oraz z MyAccountPage) - } -} diff --git a/src/test/java/tests/LoginTests.java b/src/test/java/tests/LoginTests.java new file mode 100644 index 0000000..47bfcf5 --- /dev/null +++ b/src/test/java/tests/LoginTests.java @@ -0,0 +1,36 @@ +package tests; + +import org.junit.jupiter.api.Test; +import pageobjects.BasePage; +import pageobjects.HomePage; +import pageobjects.LoginPage; + +public class LoginTests extends BaseTests { + @Test + void clickSignInButtonAndGoLoginForm() { + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); // Open main Page + + BasePage basePage = new BasePage(driver, wait); + basePage.clickSignIn(); + + LoginPage loginPage = new LoginPage(driver, wait); + loginPage.signInToRegisteredAccount(); + + loginPage.signInToNotRegisteredAccount(); + } + + // negative test: signInToNotRegisteredAccount + @Test + void clickSignInButtonAndGoToLoginFormNegative() { + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); // Open main Page + + BasePage basePage = new BasePage(driver, wait); + basePage.clickSignIn(); + + LoginPage loginPage = new LoginPage(driver, wait); + loginPage.signInToNotRegisteredAccount(); + // assertion + } +} \ No newline at end of file diff --git a/src/test/java/tests/NavigationMenuTest.java b/src/test/java/tests/NavigationMenuTest.java deleted file mode 100644 index 40565aa..0000000 --- a/src/test/java/tests/NavigationMenuTest.java +++ /dev/null @@ -1,4 +0,0 @@ -package tests; - -public class NavigationMenuTest { -} diff --git a/src/test/java/tests/RegisterTest.java b/src/test/java/tests/RegisterTest.java deleted file mode 100644 index 79338cd..0000000 --- a/src/test/java/tests/RegisterTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Test; -import pageobjects.LoginPage; -import pageobjects.RegisterPage; -import utils.RandomUser; - -public class RegisterTest extends BaseTest { - - @Test - void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() { - - RandomUser user = new RandomUser(); - System.out.println(user); - - LoginPage loginPage = new LoginPage(driver, wait); - loginPage.goToRegisterForm(user.email); - - RegisterPage registerPage = new RegisterPage(driver, wait); - registerPage.registerUser(user); - } - - @Test - void shouldNoRegisterNewUserWhenNotAllMandatoryDataIsProvided() { - // nie należy rejestrować nowego użytkownika, gdy nie podano wszystkich obowiązkowych danych - // implementacja testu (korzystamy z imilementacji RandomUser, z LoginPage oraz z RegisterPage) - } - - @Test - void shouldNoRegisterNewUserWhenIncorrectValueOfMandatoryDataIsProvided() { - // nie należy rejestrować nowego użytkownika w przypadku podania nieprawidłowej wartości obowiązkowych danych - // implementacja testu (korzystamy z implementacji RandomUser, z LoginPage oraz z RegisterPage) - } -} diff --git a/src/test/java/tests/RegisterTests.java b/src/test/java/tests/RegisterTests.java new file mode 100644 index 0000000..19bd7ab --- /dev/null +++ b/src/test/java/tests/RegisterTests.java @@ -0,0 +1,24 @@ +package tests; + +import org.junit.jupiter.api.Test; +import pageobjects.HomePage; +import pageobjects.LoginPage; +import pageobjects.RegisterPage; +import utils.RandomUser; + +public class RegisterTests extends BaseTests { + @Test + void shouldRegisterNewUserWhenAllMandatoryDataIsProvided() throws InterruptedException { // positive registration + RandomUser user = new RandomUser(); + System.out.println(user); // we print used user to test. It's needed as log for tests + + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); // Open main Page + + LoginPage loginPage = new LoginPage(driver, wait); + loginPage.goToRegisterForm(); + + RegisterPage registerPage = new RegisterPage(driver, wait); + registerPage.registerUser(user); + } +} \ No newline at end of file diff --git a/src/test/java/tests/SearchResultTests.java b/src/test/java/tests/SearchResultTests.java new file mode 100644 index 0000000..c0ac2b7 --- /dev/null +++ b/src/test/java/tests/SearchResultTests.java @@ -0,0 +1,24 @@ +package tests; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import pageobjects.HomePage; +import pageobjects.SearchResultPage; + +// extends mean that we load every elements from class BaseTests to class SearchTests +public class SearchResultTests extends BaseTests { + @Test + void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { + // because our method from class HomePage are not static so we must create object + HomePage homePage = new HomePage(driver, wait); + homePage.openPage(); // Open main Page + homePage.searchForProduct("dress"); // give searching keyword in search box + // every open new page we need to create new object of this page SearchResultPage searchResultPage = new SearchResultPage(driver, wait); + SearchResultPage searchResultPage = new SearchResultPage(driver, wait); + // here we have object from class SearchResultPage so now we can execute on this object some methods + // adding assertion to check if search result is correct (shown find product names) + + Assertions.assertTrue(searchResultPage.isProductWithNameVisible("dress")); + Assertions.assertEquals("7 results have been found.", searchResultPage.getSearchSummary()); + } +} \ No newline at end of file diff --git a/src/test/java/tests/SearchTest.java b/src/test/java/tests/SearchTest.java deleted file mode 100644 index 4d5df9c..0000000 --- a/src/test/java/tests/SearchTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package tests; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import pageobjects.HomePage; -import pageobjects.SearchResultPage; - -public class SearchTest extends BaseTest { - - @Test - void shouldReturnCorrectProductListWhenPositiveSearchPhraseIsUsed() { - // powinien zwrócić poprawną listę produktów, gdy użyto pozytywnej frazy wyszukiwania - - HomePage homePage = new HomePage(driver, wait); - homePage.openPage(); - homePage.searchForProduct("dress"); - - SearchResultPage searchResultPage = new SearchResultPage(driver, wait); - Assertions.assertTrue(searchResultPage.isProductWithNameVisible("dress")); - Assertions.assertEquals("7 results have been found.", searchResultPage.getSearchSummary()); - } - - @Test - void shouldNotReturnCorrectProductListWhenNegativeSearchPhraseIsUsed() { - // nie powinien zwracać prawidłowej listy produktów, gdy używana jest wykluczająca fraza wyszukiwania - } -} diff --git a/src/test/java/utils/RandomUser.java b/src/test/java/utils/RandomUser.java index 53274cf..990bffd 100644 --- a/src/test/java/utils/RandomUser.java +++ b/src/test/java/utils/RandomUser.java @@ -1,15 +1,27 @@ package utils; import com.github.javafaker.Faker; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import java.util.Random; public class RandomUser { + @FindBy(id = "id_gender1") + WebElement CustomerGender1; + + @FindBy(id = "id_gender2") + WebElement CustomerGender2; + // we create pools we need to registration public String firstName; public String lastName; public String email; public String password; public String address1; - public int zipCode; + public String phoneNumber; + public String city; + public String zipCode; public int dayOfBirth; public int monthOfBirth; public int yearOfBirth; @@ -19,8 +31,11 @@ public RandomUser() { firstName = faker.name().firstName(); lastName = faker.name().lastName(); yearOfBirth = faker.random().nextInt(1910, 2020); - email = firstName + lastName + yearOfBirth + "gmail.com"; - zipCode = faker.random().nextInt(10000, 99999); + email = firstName + lastName + yearOfBirth + "@gmail.com"; + zipCode = faker.random().nextInt(10000, 99999).toString(); + password = faker.pokemon().name() + yearOfBirth; + phoneNumber = faker.numerify("#########"); + city = faker.address().city(); } @Override @@ -37,4 +52,9 @@ public String toString() { ", yearOfBirth=" + yearOfBirth + '}'; } -} + + public static void main(String[] args) { + RandomUser user = new RandomUser(); + System.out.println(user); + } +} \ No newline at end of file From 66bf9494eaf7aaefac3becf3e179fcb0e1d111b1 Mon Sep 17 00:00:00 2001 From: Nikita Rysiev <74302800+MrPenguin-dev@users.noreply.github.com> Date: Thu, 24 Dec 2020 19:53:34 +0100 Subject: [PATCH 11/11] Updated README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46628ef..f106bd6 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,13 @@ ## Added: + | to pageobjects: | to tests: | to utils: | | --------------------- |:---------------------:|-----------:| | BasePage | BaseTest | RandomUser | | HomePage | CartTest | | -| LoginPage | LoginTest | | | ExecutionOfOrdersPage | ExecutionOfOrdersTest | | +| LoginPage | LoginTest | | | ProductsPage | RegisterTest | | | RegisterPage | SearchTest | | | SearchResultPage | | |