diff --git a/Rukavishnikova/src/test/java/ru/oriflame/tests/MainPageTest.java b/Rukavishnikova/src/test/java/ru/oriflame/tests/MainPageTest.java index 95d2e15..d64392c 100644 --- a/Rukavishnikova/src/test/java/ru/oriflame/tests/MainPageTest.java +++ b/Rukavishnikova/src/test/java/ru/oriflame/tests/MainPageTest.java @@ -1,75 +1,70 @@ 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.MainPage; -import static java.util.concurrent.TimeUnit.SECONDS; - public class MainPageTest { - private static WebDriver driver; - private static MainPage mainPage; - + private final static String APP_URL = "https://www.oriflame.ru/products/product?code=32418"; + private static Context context; @BeforeClass public static void setup() { - System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe"); - driver = new ChromeDriver(); - mainPage = new MainPage(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 checkHeightMenu() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class); mainPage.faceClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/skincare"))); + Assert.assertTrue(MainPage.assertHeightMenu()); } @Test public void checkProfileCap() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class); mainPage.registrClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue(url.contains("https://www.oriflame.ru/business-opportunity/become-consultant")); + Assert.assertTrue(MainPage.assertRegister()); } @Test public void checkDown() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class); + mainPage.mainClick(); mainPage.podvalClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://oriflame.com"))); + Assert.assertTrue(MainPage.assertDown()); } @Test public void checkBasementLink() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class); + mainPage.mainClick(); mainPage.bannerClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/products/product?code=33959"))); + Assert.assertTrue(MainPage.assertBanner()); } @Test public void checkProduct() { - TestCase.assertTrue("Testing if true holds", true); + context.getDriver().get(APP_URL); + MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class); + mainPage.faceClick(); mainPage.productClick(); - String url = driver.getCurrentUrl(); - Assert.assertTrue((url.contains("https://www.oriflame.ru/products/product?code=32440"))); + Assert.assertTrue(MainPage.assertProduct()); } - - @AfterClass - public static void chromeClose() { - driver.quit(); - } - }