diff --git a/Rukavishnikova/src/test/java/ru/oriflame/tests/SortByTest.java b/Rukavishnikova/src/test/java/ru/oriflame/tests/SortByTest.java index f55c113..843ddfe 100644 --- a/Rukavishnikova/src/test/java/ru/oriflame/tests/SortByTest.java +++ b/Rukavishnikova/src/test/java/ru/oriflame/tests/SortByTest.java @@ -1,53 +1,46 @@ 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.testng.Assert; +import org.openqa.selenium.support.PageFactory; +import ru.oriflame.context.ChromeContext; +import ru.oriflame.context.Context; import ru.oriflame.pages.SortBy; -import static java.util.concurrent.TimeUnit.SECONDS; - public class SortByTest { - public static WebDriver driver; - public static SortBy sortBy; + private final static String APP_URL = "https://www.oriflame.ru"; + private static Context context; @BeforeClass public static void setup() { - System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe"); - driver = new ChromeDriver(); - sortBy = new SortBy(driver); - driver.manage().window().maximize(); - driver.manage().timeouts().implicitlyWait(20, SECONDS); - driver.get("https://www.oriflame.ru"); + context = new ChromeContext(); + context.start(); + } + + @AfterClass + public static void quit() { + context.close(); } @Test public void checkShowMenuSort() { - - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + SortBy sortBy = PageFactory.initElements(context.getDriver(), SortBy.class); sortBy.faceClick(); sortBy.sortByClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/skincare"))); + Assert.assertTrue(sortBy.assertShowMenuSort()); } @Test public void checkLinkBySort() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + SortBy sortBy = PageFactory.initElements(context.getDriver(), SortBy.class); sortBy.faceClick(); sortBy.sortByClick(); sortBy.sortByPopularClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue(url.contains("https://www.oriflame.ru/skincare/?sort=popular")); - } - - @AfterClass - public static void closeChrome() { - driver.close(); + Assert.assertTrue(sortBy.assertcheckLinkBySort()); } }