use of org.jenkinsci.test.acceptance.utils.SauceLabsConnection 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);
}
}
use of org.jenkinsci.test.acceptance.utils.SauceLabsConnection in project acceptance-test-harness by jenkinsci.
the class FallbackConfig method createWebDriver.
private WebDriver createWebDriver(TestName testName) throws IOException {
String browser = System.getenv("BROWSER");
if (browser == null)
browser = "firefox";
browser = browser.toLowerCase(Locale.ENGLISH);
String display = getBrowserDisplay();
switch(browser) {
case "firefox":
FirefoxProfile profile = new FirefoxProfile();
profile.setAlwaysLoadNoFocusLib(true);
profile.setPreference(LANGUAGE_SELECTOR, "en");
// Config screen with many plugins can cause FF to complain JS takes too long to complete - set longer timeout
profile.setPreference(DOM_MAX_SCRIPT_RUN_TIME, (int) getElasticTime().seconds(600));
profile.setPreference(DOM_MAX_CHROME_SCRIPT_RUN_TIME, (int) getElasticTime().seconds(600));
FirefoxBinary binary = new FirefoxBinary();
if (display != null) {
binary.setEnvironmentProperty("DISPLAY", display);
}
return new FirefoxDriver(binary, profile);
case "ie":
case "iexplore":
case "iexplorer":
return new InternetExplorerDriver();
case "chrome":
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", Collections.singletonMap(LANGUAGE_SELECTOR, "en"));
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
if (display != null) {
builder.withEnvironment(Collections.singletonMap("DISPLAY", display));
}
return new ChromeDriver(builder.build(), 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 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), DesiredCapabilities.firefox());
default:
throw new Error("Unrecognized browser type: " + browser);
}
}
Aggregations