From 6039438f6e8176ccf6c6af9a11d18e536d583b96 Mon Sep 17 00:00:00 2001 From: Kochkaleva Date: Thu, 29 Nov 2018 11:28:00 +0400 Subject: [PATCH] Edit tests --- Kochkaleva/src/test/java/pages/Email.java | 8 ++++ .../src/test/java/pages/Navigation.java | 47 +++++++++++++++++- Kochkaleva/src/test/java/pages/Sort.java | 11 +++++ .../src/test/java/tests/EmailTests.java | 14 ++++-- .../src/test/java/tests/NavigationTests.java | 48 +++++++++++++++---- Kochkaleva/src/test/java/tests/SortTests.java | 8 ++++ 6 files changed, 123 insertions(+), 13 deletions(-) diff --git a/Kochkaleva/src/test/java/pages/Email.java b/Kochkaleva/src/test/java/pages/Email.java index 56abc84..fed0a20 100644 --- a/Kochkaleva/src/test/java/pages/Email.java +++ b/Kochkaleva/src/test/java/pages/Email.java @@ -72,4 +72,12 @@ public class Email { public void logInButtonClick() { logInButton.click(); } + + public void logInButtonDisplayed() { + if (logInButton != null) { + + } else { + throw new IllegalStateException("Element is missing, should be displayed"); + } + } } diff --git a/Kochkaleva/src/test/java/pages/Navigation.java b/Kochkaleva/src/test/java/pages/Navigation.java index 4298c5e..3741566 100644 --- a/Kochkaleva/src/test/java/pages/Navigation.java +++ b/Kochkaleva/src/test/java/pages/Navigation.java @@ -18,7 +18,7 @@ public class Navigation { @FindBy(xpath = "/html/body/div[7]/div[1]/div/div[4]/div/a[1]") private WebElement yesCityButton; - @FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/a") + @FindBy(id = "cat_cat308680401") private WebElement saleLink; @FindBy(xpath = "//*[@id=\"cat_cat308680401\"]/div/div/div/div/ul/li[1]/a") @@ -30,6 +30,51 @@ public class Navigation { @FindBy(xpath = "//*[@id=\"atg_store_footer\"]/div[3]/div/ul/li[2]/div[1]/div/a[2]") private WebElement socialElementLink; + @FindBy(xpath = "//*[@id=\"group\"]/div[1]/div[2]/div[2]/h2") + private WebElement pageName; + + @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/ul/li[1]") + private WebElement displayedPromo; + + @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[1]/h1") + private WebElement mainTitle; + + @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div/div[1]/div/div[1]/a") + private WebElement womenSales; + + public void womaneSalesLink() { + if (womenSales != null) {} + else { + throw new IllegalStateException("element is missing"); + } + } + + public void setMainTitle() { + String title = mainTitle.getAttribute("InnerText"); + if (title.equals("Распродажа женской одежды O`STIN")) { + + } else { + throw new IllegalStateException("something went wrong"); + } + } + + public void setDisplayedPromo() { + if (displayedPromo != null) { + + } else { + throw new IllegalStateException("element is missing"); + } + } + + public void setPageName() { + String title = pageName.getAttribute("InnerText"); + if (title.equals("O'STIN | ОСТИН")) { + + } else { + throw new IllegalStateException("something went wrong"); + } + } + private void setCurrentCity() { if (yesCityButton != null) { yesCityButton.click(); diff --git a/Kochkaleva/src/test/java/pages/Sort.java b/Kochkaleva/src/test/java/pages/Sort.java index 8c1eba3..75f2177 100644 --- a/Kochkaleva/src/test/java/pages/Sort.java +++ b/Kochkaleva/src/test/java/pages/Sort.java @@ -53,6 +53,17 @@ public class Sort { @FindBy(id = "atg_store_searchInput") private WebElement searchField; + @FindBy(xpath = "//*[@id=\"atg_store_content\"]/div[2]/div[2]/div[3]/div/div/b[1]") + private WebElement searchingRequset; + + public void setSearchingRequset() { + if (searchingRequset != null) { + + } else { + throw new IllegalStateException(" this"); + } + } + public static int random(int lowerBound, int upperBound) { return (lowerBound + (int) Math.round(Math.random() * (upperBound - lowerBound))); diff --git a/Kochkaleva/src/test/java/tests/EmailTests.java b/Kochkaleva/src/test/java/tests/EmailTests.java index 8e2dc49..2f27b00 100644 --- a/Kochkaleva/src/test/java/tests/EmailTests.java +++ b/Kochkaleva/src/test/java/tests/EmailTests.java @@ -48,7 +48,7 @@ public class EmailTests { public void checkForLogIn() { boolean pass = false; email.logInLinkCLick(); - // В кавычках ниже заполнить данными + //В кавычках ниже заполнить данными email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj"); email.logInButtonClick(); try { @@ -56,17 +56,23 @@ public class EmailTests { } catch (IllegalStateException e) { pass = true; } - Assert.assertTrue("login link is missing,successfully log", pass); + Assert.assertTrue("login link is missing, successfully log", pass); } @Test public void checkForLogOut() { + boolean pass = false; email.logInLinkCLick(); email.fillFields("asda@dasd.asd", "12312eqs"); email.logInButtonClick(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - String url = context.getDriver().getCurrentUrl(); - Assert.assertTrue(url.contains("https://ostin.com/#")); + try { + email.logInButtonDisplayed(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("test passed", pass); } @After diff --git a/Kochkaleva/src/test/java/tests/NavigationTests.java b/Kochkaleva/src/test/java/tests/NavigationTests.java index 204a73d..d60b6a6 100644 --- a/Kochkaleva/src/test/java/tests/NavigationTests.java +++ b/Kochkaleva/src/test/java/tests/NavigationTests.java @@ -35,33 +35,65 @@ public class NavigationTests { @Test public void checkForSaleRedirect() { + boolean pass = false; navigation.saleLinkClick(); - String url = context.getDriver().getCurrentUrl(); - Assert.assertTrue(url.contains("https://ostin.com/ru/ru/catalog/sale/?m=SaleMarker")); + /*String url = context.getDriver().getCurrentUrl(); + Assert.assertTrue(url.contains("https://ostin.com/ru/ru/catalog/sale/?m=SaleMarker"));*/ + try { + navigation.womaneSalesLink(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("test passed", pass); } @Test public void checkForFemalesSaleRedirect() { + boolean pass = false; navigation.saleFemaleLinkClick(); - String url = context.getDriver().getCurrentUrl(); + /*String url = context.getDriver().getCurrentUrl(); Assert.assertTrue(url - .contains("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_odejda_sale/?m=SaleMarker")); + .contains("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_odejda_sale/?m=SaleMarker"));*/ + try { + navigation.setMainTitle(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("passed", pass); } @Test public void checkForBasementLinkRedirect() { + boolean pass = false; navigation.basementLinkClick(); - String url = context.getDriver().getCurrentUrl(); - Assert.assertTrue(url.contains("https://ostin.com/ru/ru/pages/promo/")); + /*String url = context.getDriver().getCurrentUrl(); + Assert.assertTrue(url.contains("https://ostin.com/ru/ru/pages/promo/"));*/ + try { + navigation.setDisplayedPromo(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("passed", pass); } @Test public void checkForFollowSocialLink() { + boolean pass = false; navigation.socialElementLinkClcik(); Set tabs = context.getDriver().getWindowHandles(); context.getDriver().switchTo().window(Iterators.getLast(tabs.iterator())); - String url = context.getDriver().getCurrentUrl(); - Assert.assertTrue(url.contains("https://vk.com/club20367999")); + /*String url = context.getDriver().getCurrentUrl(); + Assert.assertTrue(url.contains("https://vk.com/club20367999"));*/ + try { + navigation.setPageName(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("passed", pass); } @After diff --git a/Kochkaleva/src/test/java/tests/SortTests.java b/Kochkaleva/src/test/java/tests/SortTests.java index 48d4ff6..cf78d7b 100644 --- a/Kochkaleva/src/test/java/tests/SortTests.java +++ b/Kochkaleva/src/test/java/tests/SortTests.java @@ -96,8 +96,16 @@ public class SortTests { @Test public void checkForSearch() { + boolean pass = false; sort.searching("куртка"); context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); + try { + sort.setSearchingRequset(); + pass = true; + } catch (IllegalStateException e) { + e.printStackTrace(); + } + Assert.assertTrue("passed", pass); } @After