From 6c97e12bd2dd3f80a57564e3aa8c8e241bd18b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BA=D0=B0=D1=82=D0=B5=D1=80=D0=B8=D0=BD=D0=B0?= Date: Sat, 8 Dec 2018 20:44:48 +0000 Subject: [PATCH] Update SearchingTest.java --- .../java/ru/oriflame/tests/SearchingTest.java | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/Rukavishnikova/src/test/java/ru/oriflame/tests/SearchingTest.java b/Rukavishnikova/src/test/java/ru/oriflame/tests/SearchingTest.java index 83e40cc..473beb6 100644 --- a/Rukavishnikova/src/test/java/ru/oriflame/tests/SearchingTest.java +++ b/Rukavishnikova/src/test/java/ru/oriflame/tests/SearchingTest.java @@ -1,51 +1,48 @@ package ru.oriflame.tests; -import junit.framework.TestCase; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.support.PageFactory; +import ru.oriflame.context.ChromeContext; +import ru.oriflame.context.Context; import ru.oriflame.pages.Search; -import static java.util.concurrent.TimeUnit.SECONDS; - public class SearchingTest { - public static WebDriver driver; - public static Search search; + + private final static String APP_URL = "https://oriflame.ru/"; + private static Context context; + String search1 = "шампунь"; + String search2 = "123"; + @BeforeClass public static void setup() { - System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe"); - driver = new ChromeDriver(); - search = new Search(driver); - driver.manage().window().maximize(); - driver.manage().timeouts().implicitlyWait(20, SECONDS); - driver.get("https://oriflame.ru/"); - } - - @Test - public void checkSearchingByKeyWords() throws InterruptedException { - TestCase.assertTrue("Testing if true holds", true); - search.inputSearchField("шампунь"); - search.clickSearchingButton(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/search?query=шампунь"))); - } - - @Test - public void checkSearchingByNumb() throws InterruptedException { - TestCase.assertTrue("Testing if true holds", true); - search.inputSearchField("123"); - search.clickSearchingButton(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/search?query=123"))); + context = new ChromeContext(); + context.start(); } @AfterClass - public static void cromeClose() { - driver.close(); + public static void quit() { + context.close(); } + @Test + public void checkSearchingByKeyWords() { + context.getDriver().get(APP_URL); + Search search = PageFactory.initElements(context.getDriver(), Search.class); + search.inputSearchField(search1); + search.clickSearchingButton(); + Assert.assertTrue(search.checkSearch(search1)); + } + + @Test + public void checkSearchingByNumb() { + context.getDriver().get(APP_URL); + Search search = PageFactory.initElements(context.getDriver(), Search.class); + search.inputSearchField(search2); + search.clickSearchingButton(); + Assert.assertTrue(search.checkSearch(search2)); + } }