41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
package context;
|
|
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
import org.openqa.selenium.chrome.ChromeOptions;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class ChromeContext extends Context {
|
|
private final static String WINDOWS_DRIVER = "chromedriver.exe";
|
|
private final static String LINUX_DRIVER = "chromedriver";
|
|
private final static String DRIVER_TYPE = "webdriver.chrome.driver";
|
|
|
|
|
|
@Override
|
|
protected void createDriver() {
|
|
ChromeOptions options = new ChromeOptions();
|
|
Map<String, Object> prefs = new HashMap<String, Object>();
|
|
prefs.put("plugins.always_open_pdf_externally", true);
|
|
// tmpPath = System.getProperty("java.io.tmpdir");
|
|
|
|
tmpPath = System.getProperty("user.dir") + "/src/main/resources/downloads/";
|
|
|
|
prefs.put("download.default_directory", tmpPath);
|
|
options.setExperimentalOption("prefs",prefs);
|
|
|
|
driver = new ChromeDriver(options);
|
|
}
|
|
|
|
@Override
|
|
protected String getDriverExecutable(boolean isWindows) {
|
|
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
|
}
|
|
|
|
@Override
|
|
protected String getDriverType() {
|
|
return DRIVER_TYPE;
|
|
}
|
|
|
|
}
|