58 lines
1.8 KiB
Java
58 lines
1.8 KiB
Java
package org.example;
|
||
import java.time.Duration;
|
||
|
||
import org.aeonbits.owner.ConfigFactory;
|
||
import org.example.config.BaseCofig;
|
||
import org.openqa.selenium.WebDriver;
|
||
import org.openqa.selenium.chrome.ChromeDriver;
|
||
import org.testng.annotations.AfterMethod;
|
||
import org.testng.annotations.BeforeMethod;
|
||
|
||
/**
|
||
* Общий класс с настройками для всех тестов
|
||
*/
|
||
public abstract class BaseTest {
|
||
|
||
//создание экземпляра драйвера
|
||
/**
|
||
* Переменная с экземпляром драйвера
|
||
*/
|
||
protected WebDriver driver;
|
||
|
||
/**
|
||
* Экземпляр конфигурации с общими параметрами
|
||
*/
|
||
|
||
private final BaseCofig config = ConfigFactory.create(BaseCofig.class, System.getenv());
|
||
|
||
/**
|
||
* Общие настройки для всех тестов, перед выполнением каждого
|
||
*/
|
||
@BeforeMethod
|
||
public void setUp(){
|
||
//Установка настройки с путём к Google драйверу
|
||
System.setProperty(config.driverProperty(), config.driverPath());
|
||
|
||
//Создание экземпляра драйвера
|
||
driver = new ChromeDriver();
|
||
|
||
//открытие страницы Google по url
|
||
driver.get(config.url());
|
||
|
||
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));
|
||
//разворот окна на полный экран при открытии
|
||
driver.manage().window().maximize();
|
||
}
|
||
|
||
/**
|
||
* Общие настройки для всех тестов, после выполнения каждого теста
|
||
*/
|
||
@AfterMethod
|
||
public void tearDown() throws InterruptedException {
|
||
|
||
//Остановка работы драйвера
|
||
driver.close();
|
||
}
|
||
|
||
}
|