From 7a08e1ec83bde9a4ace1c30d058a39efeba4ad19 Mon Sep 17 00:00:00 2001 From: romanov73 Date: Fri, 16 Feb 2018 14:18:07 +0400 Subject: [PATCH] add tests --- pom.xml | 5 ++++ src/main/java/ru/ulstu/tis/Main.java | 2 +- src/test/java/YandexSearch.java | 40 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/test/java/YandexSearch.java diff --git a/pom.xml b/pom.xml index f3ab0e1..4b647d9 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,11 @@ selenium-java 3.6.0 + + org.junit.jupiter + junit-jupiter-api + 5.1.0-RC1 + diff --git a/src/main/java/ru/ulstu/tis/Main.java b/src/main/java/ru/ulstu/tis/Main.java index 972907e..ddb8d7b 100644 --- a/src/main/java/ru/ulstu/tis/Main.java +++ b/src/main/java/ru/ulstu/tis/Main.java @@ -11,10 +11,10 @@ import java.util.concurrent.TimeUnit; public class Main { private final static String APP_URL = "http://ya.ru"; + private final static String DRIVER_TYPE = "webdriver.chrome.driver"; private final static String DRIVER_LOCATION = "drivers/%s"; private final static String WINDOWS_CHROME_DRIVER = "chromedriver.exe"; private final static String LINUX_CHROME_DRIVER = "chromedriver"; - private final static String DRIVER_TYPE = "webdriver.chrome.driver"; public static void main(String[] args) { diff --git a/src/test/java/YandexSearch.java b/src/test/java/YandexSearch.java new file mode 100644 index 0000000..ea6554d --- /dev/null +++ b/src/test/java/YandexSearch.java @@ -0,0 +1,40 @@ +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeDriver; +import ru.ulstu.tis.Main; + +import java.util.concurrent.TimeUnit; + + +public class YandexSearch { + + private final static String DRIVER_TYPE = "webdriver.chrome.driver"; + private final static String DRIVER_LOCATION = "drivers/%s"; + private final static String WINDOWS_CHROME_DRIVER = "chromedriver.exe"; + private final static String LINUX_CHROME_DRIVER = "chromedriver"; + + private static WebDriver driver; + + @BeforeAll + public static void setup() { + System.setProperty(DRIVER_TYPE, getDriverExecutable()); + driver = new ChromeDriver(); + driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); + } + + @Test + public void testGetFreeEmployeesNextUnits() { + } + + @AfterAll + public static void quit() { + + driver.quit(); + } + + private static String getDriverExecutable() { + return YandexSearch.class.getClassLoader().getResource(String.format(DRIVER_LOCATION, WINDOWS_CHROME_DRIVER)).getFile(); + } +}