Kochkaleva e8b00cbe09 Bugfix
2018-11-27 13:45:06 +04:00

46 lines
1.2 KiB
Java

package helpers;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
public abstract class Context {
private final static String DRIVER_LOCATION = "src\\main\\resources\\chromedriver.exe";
protected WebDriver driver;
public WebDriver getDriver() {
if (driver != null) {
return driver;
}
throw new IllegalStateException("WebDriver is not initialized");
}
public void start() {
System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
public void close() {
driver.quit();
}
protected abstract void createDriver();
protected abstract String getDriverType();
protected abstract String getDriverExecutable(boolean windows);
private String getDriverExecutablePath() {
System.setProperty("webdriver.chrome.driver", DRIVER_LOCATION);
return null;
}
private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}
}