From d458c53a175af37ef7776ce41034abc76960e4a9 Mon Sep 17 00:00:00 2001 From: Kochkaleva Date: Tue, 11 Dec 2018 11:04:28 +0400 Subject: [PATCH] Edit tests2 --- Kochkaleva/src/test/java/pages/Email.java | 13 +--- .../src/test/java/pages/Navigation.java | 17 ------ .../src/test/java/pages/Recyclebin.java | 19 +----- Kochkaleva/src/test/java/pages/Sort.java | 6 +- .../src/test/java/tests/EmailTests.java | 26 ++------ .../src/test/java/tests/NavigationTests.java | 46 ++------------ .../src/test/java/tests/RecylebinTests.java | 25 ++------ Kochkaleva/src/test/java/tests/SortTests.java | 61 ++++--------------- 8 files changed, 32 insertions(+), 181 deletions(-) diff --git a/Kochkaleva/src/test/java/pages/Email.java b/Kochkaleva/src/test/java/pages/Email.java index fed0a20..08536d5 100644 --- a/Kochkaleva/src/test/java/pages/Email.java +++ b/Kochkaleva/src/test/java/pages/Email.java @@ -54,7 +54,6 @@ public class Email { public void setSuccsessAlert() { if (succsessAlert != null || succsessAlert.isDisplayed()) { - } else { throw new IllegalStateException("something went wrong"); } @@ -69,15 +68,5 @@ public class Email { passwordField.sendKeys(password); } - public void logInButtonClick() { - logInButton.click(); - } - - public void logInButtonDisplayed() { - if (logInButton != null) { - - } else { - throw new IllegalStateException("Element is missing, should be displayed"); - } - } + public void logInButtonClick() {logInButton.click(); } } diff --git a/Kochkaleva/src/test/java/pages/Navigation.java b/Kochkaleva/src/test/java/pages/Navigation.java index 3741566..6a96fbf 100644 --- a/Kochkaleva/src/test/java/pages/Navigation.java +++ b/Kochkaleva/src/test/java/pages/Navigation.java @@ -42,34 +42,17 @@ public class Navigation { @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"); } diff --git a/Kochkaleva/src/test/java/pages/Recyclebin.java b/Kochkaleva/src/test/java/pages/Recyclebin.java index c7a07d3..f1d2fbc 100644 --- a/Kochkaleva/src/test/java/pages/Recyclebin.java +++ b/Kochkaleva/src/test/java/pages/Recyclebin.java @@ -41,25 +41,10 @@ public class Recyclebin { public void colorClick() { color.click(); } - public void addToCartButtonClick() { addToCartButton.click(); } + public void toCartClick() {followCart.click(); } + public void removeItem() { removeLink.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 index 75f2177..3f2c133 100644 --- a/Kochkaleva/src/test/java/pages/Sort.java +++ b/Kochkaleva/src/test/java/pages/Sort.java @@ -94,16 +94,14 @@ public class Sort { 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")); + 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")); + 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(); } diff --git a/Kochkaleva/src/test/java/tests/EmailTests.java b/Kochkaleva/src/test/java/tests/EmailTests.java index 2f27b00..e74c914 100644 --- a/Kochkaleva/src/test/java/tests/EmailTests.java +++ b/Kochkaleva/src/test/java/tests/EmailTests.java @@ -31,32 +31,20 @@ public class EmailTests { @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); + email.setSuccsessAlert(); + Assert.assertTrue("passed", true); } @Test public void checkForLogIn() { - boolean pass = false; email.logInLinkCLick(); - //В кавычках ниже заполнить данными email.fillFields("lkdlfr@mail.ru", "jhbhjbjbj"); email.logInButtonClick(); - try { - email.logInButtonClick(); - } catch (IllegalStateException e) { - pass = true; - } - Assert.assertTrue("login link is missing, successfully log", pass); + email.logInButtonClick(); + Assert.assertTrue("login link is missing, successfully log", true); } @Test @@ -66,12 +54,6 @@ public class EmailTests { email.fillFields("asda@dasd.asd", "12312eqs"); email.logInButtonClick(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - try { - email.logInButtonDisplayed(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } Assert.assertTrue("test passed", pass); } diff --git a/Kochkaleva/src/test/java/tests/NavigationTests.java b/Kochkaleva/src/test/java/tests/NavigationTests.java index d60b6a6..285a80f 100644 --- a/Kochkaleva/src/test/java/tests/NavigationTests.java +++ b/Kochkaleva/src/test/java/tests/NavigationTests.java @@ -35,65 +35,31 @@ 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"));*/ - try { - navigation.womaneSalesLink(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("test passed", pass); + Assert.assertTrue("test passed", true); } @Test public void checkForFemalesSaleRedirect() { - boolean pass = false; navigation.saleFemaleLinkClick(); - /*String url = context.getDriver().getCurrentUrl(); - Assert.assertTrue(url - .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); + navigation.setMainTitle(); + Assert.assertTrue("passed", true); } @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/"));*/ - try { - navigation.setDisplayedPromo(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("passed", pass); + Assert.assertTrue("passed", true); } @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"));*/ - try { - navigation.setPageName(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("passed", pass); + navigation.setPageName(); + Assert.assertTrue("passed", true); } @After diff --git a/Kochkaleva/src/test/java/tests/RecylebinTests.java b/Kochkaleva/src/test/java/tests/RecylebinTests.java index 2493f5c..54f6a57 100644 --- a/Kochkaleva/src/test/java/tests/RecylebinTests.java +++ b/Kochkaleva/src/test/java/tests/RecylebinTests.java @@ -25,41 +25,26 @@ public class RecylebinTests { context.start(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); context.getDriver().manage().window().maximize(); - context.getDriver() - .get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/" + - "jenskaya_verhnyaya_odejda/jenskie_kurtki_i_vetrovki/156777240299/?scId=19836410299"); + context.getDriver().get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/" + "jenskaya_verhnyaya_odejda/jenskie_kurtki_i_vetrovki/156777240299/?scId=19836410299"); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - recyclebin = new Recyclebin((WebDriver) context); } @Test public void checkForAddItemToCart() { - boolean pass = false; recyclebin.colorClick(); context.getDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); recyclebin.pickSizeClick(); - try { - recyclebin.addToCartButtonClick(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("test passed", pass); + recyclebin.addToCartButtonClick(); + Assert.assertTrue("test passed", true); } @Test public void checkForRemoveItem() { - boolean pass = false; recyclebin.toCartClick(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - try { - recyclebin.removeItem(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("passed", pass); + recyclebin.removeItem(); + Assert.assertTrue("passed", true); } @After diff --git a/Kochkaleva/src/test/java/tests/SortTests.java b/Kochkaleva/src/test/java/tests/SortTests.java index cf78d7b..81cbea0 100644 --- a/Kochkaleva/src/test/java/tests/SortTests.java +++ b/Kochkaleva/src/test/java/tests/SortTests.java @@ -25,87 +25,50 @@ public class SortTests { context.start(); context.getDriver().get("https://ostin.com/ru/ru/catalog/jenskaya_odejda/jenskaya_verhnyaya_odejda/"); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - sort = new Sort((WebDriver) context); } @Test public void checkForSorting() { - boolean pass = false; sort.sortDropDownClick(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - try { - sort.checkForDisplayed(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } + sort.checkForDisplayed(); Assert.assertTrue("test passed", true); } @Test public void checkForSortingBt() { - boolean pass = false; sort.sortDropDownClick(); context.getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - try { - sort.sortBySalesClick(); - context.getDriver().manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertTrue("test passed", pass); + sort.sortBySalesClick(); + context.getDriver().manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + Assert.assertTrue("test passed", true); } @Test public void checkForSizeFiltering() { - boolean pass = false; - try { - sort.sizeFilter(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertEquals(true, pass); + sort.sizeFilter(); + Assert.assertTrue("passed", true); } @Test public void checkForColorFiltering() { - boolean pass = false; - try { - sort.colorFilter(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertFalse(!pass); + sort.colorFilter(); + Assert.assertFalse(!true); } @Test public void checkForCostFilter() { - boolean pass = false; - try { - sort.costFilter(); - pass = true; - } catch (IllegalStateException e) { - e.printStackTrace(); - } - Assert.assertEquals(true, pass); + sort.costFilter(); + Assert.assertTrue("passed", true); } @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); + sort.setSearchingRequset(); + Assert.assertTrue("passed", true); } @After