diff --git a/Kochkaleva/pom.xml b/Kochkaleva/pom.xml
new file mode 100644
index 0000000..54b7d76
--- /dev/null
+++ b/Kochkaleva/pom.xml
@@ -0,0 +1,44 @@
+
+
+ 4.0.0
+
+ kochkaleva_labs
+ kochkaleva_labs
+ 1.0-SNAPSHOT
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 8
+
+
+
+
+
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 3.7.1
+
+
+
+ junit
+ junit
+ 4.12
+
+
+
+ com.github.javafaker
+ javafaker
+ 0.16
+
+
+
+
\ No newline at end of file
diff --git a/Kochkaleva/src/main/resources/chromedriver.exe b/Kochkaleva/src/main/resources/chromedriver.exe
new file mode 100644
index 0000000..4bfff1e
Binary files /dev/null and b/Kochkaleva/src/main/resources/chromedriver.exe differ
diff --git a/Kochkaleva/src/test/java/pages/Email.java b/Kochkaleva/src/test/java/pages/Email.java
new file mode 100644
index 0000000..f414b25
--- /dev/null
+++ b/Kochkaleva/src/test/java/pages/Email.java
@@ -0,0 +1,76 @@
+package pages;
+
+import com.github.javafaker.Faker;
+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 java.security.Key;
+
+public class Email {
+
+ private WebDriver driver;
+ Faker faker = new Faker();
+
+ public Email(WebDriver driver) {
+ PageFactory.initElements(driver, this);
+ this.driver = driver;
+ }
+
+ @FindBy(name = "email")
+ private WebElement emailField;
+
+ @FindBy(xpath = "//*[@id=\"subscribe_submit\"]")
+ private WebElement submitButton;
+
+ @FindBy(xpath = "//*[@id=\"subscribePopup\"]/div[1]")
+ private WebElement succsessAlert;
+
+ @FindBy(id = "loginRef")
+ private WebElement logInLink;
+
+ @FindBy(name = "login")
+ private WebElement loginField;
+
+ @FindBy(name = "password")
+ private WebElement passwordField;
+
+ @FindBy(id = "loginPopupButtonID")
+ private WebElement logInButton;
+
+
+
+ public void emailService() {
+ String firstPart = faker.name().firstName();
+ String secondPart = faker.name().lastName();
+ String domen = faker.app().name();
+ emailField.sendKeys(Keys.chord(Keys.CONTROL, "v") + firstPart + secondPart + "@" + domen + ".com");
+ }
+
+ public void submitButtonClick() {
+ submitButton.click();
+ }
+
+ public void setSuccsessAlert() {
+ if (succsessAlert != null || succsessAlert.isDisplayed()) {
+
+ } else {
+ throw new IllegalStateException("something went wrong");
+ }
+ }
+
+ public void logInLinkCLick() {
+ logInLink.click();
+ }
+
+ public void fillFields(String email,String password) {
+ emailField.sendKeys(email);
+ passwordField.sendKeys(password);
+ }
+
+ public void logInButtonClick() {
+ logInButton.click();
+ }
+}
diff --git a/Kochkaleva/src/test/java/pages/Navigation.java b/Kochkaleva/src/test/java/pages/Navigation.java
new file mode 100644
index 0000000..4298c5e
--- /dev/null
+++ b/Kochkaleva/src/test/java/pages/Navigation.java
@@ -0,0 +1,59 @@
+package pages;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+
+
+public class Navigation {
+
+ private WebDriver driver;
+
+ public Navigation(WebDriver driver) {
+ PageFactory.initElements(driver, this);
+ this.driver = driver;
+ }
+
+ @FindBy(xpath = "/html/body/div[7]/div[1]/div/div[4]/div/a[1]")
+ private WebElement yesCityButton;
+
+ @FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/a")
+ private WebElement saleLink;
+
+ @FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/div/div/div/div/ul/li[1]/a")
+ private WebElement saleFemaleLink;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_footer\"]/div[2]/div/div/div/div[1]/a[2]")
+ private WebElement basementLink;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_footer\"]/div[3]/div/ul/li[2]/div[1]/div/a[2]")
+ private WebElement socialElementLink;
+
+ private void setCurrentCity() {
+ if (yesCityButton != null) {
+ yesCityButton.click();
+ }
+ }
+
+ public void saleLinkClick() {
+ setCurrentCity();
+ saleLink.click();
+ }
+
+ public void saleFemaleLinkClick() {
+ setCurrentCity();
+ saleFemaleLink.click();
+ }
+
+ public void basementLinkClick() {
+ setCurrentCity();
+ basementLink.click();
+ }
+
+ public void socialElementLinkClcik() {
+ setCurrentCity();
+ socialElementLink.click();
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/pages/Recyclebin.java b/Kochkaleva/src/test/java/pages/Recyclebin.java
new file mode 100644
index 0000000..c7a07d3
--- /dev/null
+++ b/Kochkaleva/src/test/java/pages/Recyclebin.java
@@ -0,0 +1,65 @@
+package pages;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+
+public class Recyclebin {
+
+ private WebDriver driver;
+
+ public Recyclebin(WebDriver driver) {
+ PageFactory.initElements(driver, this);
+ this.driver = driver;
+ }
+
+ @FindBy(xpath = "//*[@id=\"sc_19836410299\"]")
+ private WebElement color;
+
+ @FindBy(id = "size_170398140299")
+ private WebElement pickSize;
+
+ @FindBy(id = "addItemToOrderID")
+ private WebElement addToCartButton;
+
+ @FindBy(xpath = "//*[@id=\"headerCart\"]/a")
+ private WebElement toCart;
+
+ @FindBy(xpath = "//*[@id=\"cartPopup\"]/div[2]/div[2]/div[2]/a")
+ private WebElement followCart;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[9]/div[2]/div/div/ul/li[1]/div/a/img")
+ private WebElement imagePoint;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[9]/div[2]/div/div/a")
+ private WebElement removeLink;
+
+ public void pickSizeClick() {
+ pickSize.click();
+ }
+ public void colorClick() {
+ color.click();
+ }
+
+ public void addToCartButtonClick() {
+ addToCartButton.click();
+ }
+
+ public void toCartClick() {
+ toCart.click();
+ if (followCart != null) {
+
+ followCart.click();
+ }
+ }
+
+ public void removeItem() {
+ if (imagePoint == null) {
+ throw new IllegalStateException("Elements is missing," +
+ " look like a bad ELF magic!");
+ } else {
+ removeLink.click();
+ }
+ }
+}
diff --git a/Kochkaleva/src/test/java/pages/Sort.java b/Kochkaleva/src/test/java/pages/Sort.java
new file mode 100644
index 0000000..c95bfab
--- /dev/null
+++ b/Kochkaleva/src/test/java/pages/Sort.java
@@ -0,0 +1,102 @@
+package pages;
+
+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;
+
+public class Sort {
+
+ private WebDriver driver;
+
+ public Sort(WebDriver driver) {
+ PageFactory.initElements(driver, this);
+ this.driver = driver;
+ }
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[1]/div/form/div/i")
+ private WebElement sortDropDown;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[1]/div/form/div/div/div[2]/ul/li[4]")
+ private WebElement sortBySales;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[1]/div/form/div/span")
+ private WebElement sortLabel;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/i")
+ private WebElement dropDownSize;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/" +
+ "div[2]/ul/div/div/li[1]/label/input")
+ private WebElement checkBoxSize;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[2]/i")
+ private WebElement dropDownColor;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[2]/div/div[2]/ul/li[1]/label/span/i")
+ private WebElement checkBoxColor;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[3]/i")
+ private WebElement dropDownCost;
+
+ @FindBy(xpath = "//*[@id=\"searchPriceSliderMin\"]")
+ private WebElement minCostField;
+
+ @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[3]/div/div[2]/a")
+ private WebElement submitButton;
+
+ @FindBy(xpath = "//*[@id=\"searchForm\"]/a")
+ private WebElement searchButton;
+
+ @FindBy(id = "atg_store_searchInput")
+ private WebElement searchField;
+
+ public static int random(int lowerBound, int upperBound) {
+ return (lowerBound + (int) Math.round(Math.random()
+ * (upperBound - lowerBound)));
+ }
+
+ public void sortDropDownClick() {
+ sortDropDown.click();
+ }
+
+ public void sortBySalesClick() {
+ sortBySales.click();
+ }
+
+ public String setSortLabel() {
+ String labelText = sortLabel.getAttribute("innerText");
+ return labelText;
+ }
+
+ public void sizeFilter() {
+ dropDownSize.click();
+ checkBoxSize.click();
+ WebElement submit = driver.findElement(By
+ .xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
+ submit.click();
+ }
+
+ public void colorFilter() {
+ dropDownColor.click();
+ checkBoxColor.click();
+ WebElement submit = driver.findElement(By
+ .xpath("//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[2]/form/div[1]/div/div[2]/a"));
+ submit.click();
+ }
+
+ public void costFilter() {
+ int cost = random(1500, 5000);
+ dropDownCost.click();
+ minCostField.sendKeys(Integer.toString(cost));
+ submitButton.click();
+ }
+
+ public void searching(String type) {
+ searchButton.click();
+ searchField.sendKeys(type, Keys.RETURN);
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/tests/EmailTests.java b/Kochkaleva/src/test/java/tests/EmailTests.java
new file mode 100644
index 0000000..15c2cc8
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/EmailTests.java
@@ -0,0 +1,68 @@
+package tests;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import pages.Email;
+
+import java.util.concurrent.TimeUnit;
+
+public class EmailTests {
+
+ private static WebDriver driver;
+ private static Email email;
+
+ @Before
+ public void setUp() {
+ System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");
+ driver = new ChromeDriver();
+
+ driver.manage().window().maximize();
+ driver.get("https://ostin.com/");
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+ email = new Email(driver);
+ }
+
+ @Test
+ public void checkForFollow() throws InterruptedException {
+ boolean pass = false;
+ Thread.sleep(3000);
+ email.emailService();
+ email.submitButtonClick();
+ try {
+ email.setSuccsessAlert();
+ pass = true;
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ Assert.assertTrue("passed", pass);
+ }
+
+ @Test
+ public void checkForLogIn() {
+ email.logInLinkCLick();
+ // В кавычках ниже заполнишь своими данными.
+ email.fillFields("", "");
+ email.logInButtonClick();
+ }
+
+ @Test
+ public void checkForLogOut() {
+ email.logInLinkCLick();
+ email.fillFields("asda@dasd.asd", "12312eqs");
+ email.logInButtonClick();
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+
+ }
+
+ @After
+ public void quit() {
+ driver.quit();
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/tests/JUnitTestReporter.java b/Kochkaleva/src/test/java/tests/JUnitTestReporter.java
new file mode 100644
index 0000000..7d3706f
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/JUnitTestReporter.java
@@ -0,0 +1,82 @@
+package tests;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import java.awt.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.Locale;
+
+public class JUnitTestReporter {
+ final static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("EEEE MMM d, YYYY", Locale.CANADA);
+
+ static File junitReport;
+ static BufferedWriter junitWriter;
+
+ @BeforeClass
+ public void setUp() throws IOException {
+ DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
+ Date date = new Date();
+
+ String junitReportFile = System.getProperty("user.dir")
+ + "\\ReportFile" + LocalDate.now().format(dateFormatter) + ".html";
+ junitReport = new File(junitReportFile);
+ junitWriter = new BufferedWriter(new FileWriter(junitReport, true));
+ junitWriter.write("
");
+ junitWriter.write("Test Execution Summary - " + dateFormat.format(date)
+ + "
");
+
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException {
+
+ junitWriter.write("");
+ junitWriter.close();
+ Desktop.getDesktop().browse(junitReport.toURI());
+
+ }
+
+ @Rule
+ public TestRule junitWaiter = new TestWatcher() {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return super.apply(base, description);
+ }
+
+ @Override
+ protected void succeeded(Description description) {
+ try {
+ junitWriter.write(description.getDisplayName() + " "
+ + "success!");
+ junitWriter.write("
");
+ } catch (Exception e1) {
+ System.out.println(e1.getMessage());
+ }
+ }
+
+ @Override
+ protected void failed(Throwable e, Description description) {
+ try {
+ junitWriter.write(description.getDisplayName() + " "
+ + e.getClass().getSimpleName());
+ junitWriter.write("
");
+ } catch (Exception e2) {
+ System.out.println(e2.getMessage());
+ }
+ }
+ };
+}
diff --git a/Kochkaleva/src/test/java/tests/NavigationTests.java b/Kochkaleva/src/test/java/tests/NavigationTests.java
new file mode 100644
index 0000000..5d15dba
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/NavigationTests.java
@@ -0,0 +1,71 @@
+package tests;
+
+import com.google.common.collect.Iterators;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+
+import pages.Navigation;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+public class NavigationTests {
+
+ private static WebDriver driver;
+ private static Navigation navigation;
+
+ @Before
+ public static void setUp() {
+ System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");
+ driver = new ChromeDriver();
+
+ driver.manage().window().maximize();
+ driver.get("https://ostin.com/");
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+ navigation = new Navigation(driver);
+ }
+
+ @Test
+ public void checkForSaleRedirect() {
+ navigation.saleLinkClick();
+ String url = driver.getCurrentUrl();
+ Assert.assertTrue(url.contains("https://ostin.com/ru/ru/catalog/sale/?m=SaleMarker"));
+ }
+
+ @Test
+ public void checkForFemalesSaleRedirect() {
+ navigation.saleFemaleLinkClick();
+ String url = driver.getCurrentUrl();
+ Assert.assertTrue(url
+ .contains("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_odejda_sale/?m=SaleMarker"));
+ }
+
+ @Test
+ public void checkForBasementLinkRedirect() {
+ navigation.basementLinkClick();
+ String url = driver.getCurrentUrl();
+ Assert.assertTrue(url.contains("https://ostin.com/ru/ru/pages/promo/"));
+ }
+
+ @Test
+ public void checkForFollowSocialLink() {
+ navigation.socialElementLinkClcik();
+ Set tabs = driver.getWindowHandles();
+ driver.switchTo().window(Iterators.getLast(tabs.iterator()));
+ String url = driver.getCurrentUrl();
+ Assert.assertTrue(url.contains("https://vk.com/club20367999"));
+ }
+
+ @After
+ public void quit() {
+ driver.quit();
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/tests/RecylebinTests.java b/Kochkaleva/src/test/java/tests/RecylebinTests.java
new file mode 100644
index 0000000..3f41a22
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/RecylebinTests.java
@@ -0,0 +1,60 @@
+package tests;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import pages.Recyclebin;
+
+import java.util.concurrent.TimeUnit;
+
+public class RecylebinTests {
+
+ private static WebDriver driver;
+ private static Recyclebin recyclebin;
+
+ @Before
+ public void setUp() {
+ System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");
+ driver = new ChromeDriver();
+
+ driver.manage().window().maximize();
+ driver
+ .get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/" +
+ "jenskaya_verhnyaya_odejda/jenskie_kurtki_i_vetrovki/156777240299/?scId=19836410299");
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+ recyclebin = new Recyclebin(driver);
+ }
+
+ @Test
+ public void checkForAddItemToCart() {
+ recyclebin.colorClick();
+ driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
+ recyclebin.pickSizeClick();
+ recyclebin.addToCartButtonClick();
+ Assert.assertTrue("test passed", true);
+ }
+
+ @Test
+ public void checkForRemoveItem() {
+ boolean pass = false;
+ recyclebin.toCartClick();
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+ try {
+ recyclebin.removeItem();
+ pass = true;
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ Assert.assertTrue("passed", pass);
+ }
+
+ @After
+ public void quit() {
+ driver.quit();
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/tests/RunTests.java b/Kochkaleva/src/test/java/tests/RunTests.java
new file mode 100644
index 0000000..15232e0
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/RunTests.java
@@ -0,0 +1,17 @@
+package tests;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import pages.Recyclebin;
+
+public class RunTests {
+
+ public static void main(String[] args) {
+
+ Result result = JUnitCore
+ .runClasses(NavigationTests.class, SortTests.class, EmailTests.class, Recyclebin.class);
+ System.out.println("Total number of tests: " + result.getRunCount());
+ System.out.println("Total number of tests failed: " + result.getFailureCount());
+ }
+
+}
diff --git a/Kochkaleva/src/test/java/tests/SortTests.java b/Kochkaleva/src/test/java/tests/SortTests.java
new file mode 100644
index 0000000..9d244d9
--- /dev/null
+++ b/Kochkaleva/src/test/java/tests/SortTests.java
@@ -0,0 +1,76 @@
+package tests;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+
+import pages.Sort;
+
+import java.util.concurrent.TimeUnit;
+
+public class SortTests {
+
+ private static WebDriver driver;
+ private static Sort sort;
+
+ @Before
+ public void setUp() {
+ System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");
+ driver = new ChromeDriver();
+
+ driver.manage().window().maximize();
+ driver.get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_verhnyaya_odejda/");
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+ sort = new Sort(driver);
+ }
+
+ @Test
+ public void checkForSorting() {
+ sort.sortDropDownClick();
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+
+ Assert.assertTrue("test passed", true);
+ }
+
+ @Test
+ public void checkForSortingBt() {
+ sort.sortDropDownClick();
+ driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+ sort.sortBySalesClick();
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+
+ Assert.assertTrue("test passed", true);
+ }
+
+ @Test
+ public void checkForSizeFiltering() {
+ sort.sizeFilter();
+ }
+
+ @Test
+ public void checkForColorFiltering() {
+ sort.colorFilter();
+ }
+
+ @Test
+ public void checkForCostFilter() {
+ sort.costFilter();
+ }
+
+ @Test
+ public void checkForSearch() {
+ sort.searching("куртка");
+ driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
+ }
+
+ @After
+ public void quit() {
+ driver.quit();
+ }
+
+}