use of org.openqa.selenium.firefox.GeckoDriverService in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createWebDriver.
private WebDriver createWebDriver(TestCleaner cleaner, TestName testName) throws IOException {
String browser = getBrowser();
String display = getBrowserDisplay();
switch(browser) {
case "firefox":
setDriverPropertyIfMissing("geckodriver", GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY);
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
if (display != null) {
builder.withEnvironment(Collections.singletonMap("DISPLAY", display));
}
GeckoDriverService service = builder.build();
return new FirefoxDriver(service, buildFirefoxOptions(testName));
case "firefox-container":
return createContainerWebDriver(cleaner, "selenium/standalone-firefox-debug:3.141.59", buildFirefoxOptions(testName));
case "chrome-container":
return createContainerWebDriver(cleaner, "selenium/standalone-chrome-debug:3.141.59", new ChromeOptions());
case "ie":
case "iexplore":
case "iexplorer":
return new InternetExplorerDriver();
case "chrome":
Map<String, String> prefs = new HashMap<String, String>();
prefs.put(LANGUAGE_SELECTOR, "en");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
if (isCaptureHarEnabled()) {
options.setAcceptInsecureCerts(true);
options.setProxy(createSeleniumProxy(testName.get()));
}
setDriverPropertyIfMissing("chromedriver", ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
return new ChromeDriver(options);
case "safari":
return new SafariDriver();
case "htmlunit":
return new HtmlUnitDriver(true);
case "saucelabs":
case "saucelabs-firefox":
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setCapability("version", "29");
caps.setCapability("platform", "Windows 7");
caps.setCapability("name", testName.get());
if (isCaptureHarEnabled()) {
caps.setCapability(CapabilityType.PROXY, createSeleniumProxy(testName.get()));
}
// if running inside Jenkins, expose build ID
String tag = System.getenv("BUILD_TAG");
if (tag != null)
caps.setCapability("build", tag);
return new SauceLabsConnection().createWebDriver(caps);
case "phantomjs":
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setCapability(LANGUAGE_SELECTOR, "en");
capabilities.setCapability(LANGUAGE_SELECTOR_PHANTOMJS, "en");
return new PhantomJSDriver(capabilities);
case "remote-webdriver-firefox":
String u = System.getenv("REMOTE_WEBDRIVER_URL");
if (StringUtils.isBlank(u)) {
throw new Error("remote-webdriver-firefox requires REMOTE_WEBDRIVER_URL to be set");
}
return new RemoteWebDriver(// http://192.168.99.100:4444/wd/hub
new URL(u), buildFirefoxOptions(testName));
case "remote-webdriver-chrome":
u = System.getenv("REMOTE_WEBDRIVER_URL");
if (StringUtils.isBlank(u)) {
throw new Error("remote-webdriver-chrome requires REMOTE_WEBDRIVER_URL to be set");
}
return new RemoteWebDriver(// http://192.168.99.100:4444/wd/hub
new URL(u), DesiredCapabilities.chrome());
default:
throw new Error("Unrecognized browser type: " + browser);
}
}
Aggregations