Update SortByTest.java

This commit is contained in:
Екатерина 2018-12-08 20:43:44 +00:00
parent 065d590693
commit 72643afa78

View File

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