use of org.openqa.selenium.chrome.ChromeDriver in project cia by Hack23.
the class AbstractRoleSystemTest method getWebDriver.
/**
* Gets the web driver.
*
* @return the web driver
*/
protected final synchronized WebDriver getWebDriver() {
WebDriver driver = null;
if ("firefox".equals(browser)) {
final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
driver.manage().window().maximize();
} else if ("chrome".equals(browser)) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--allow-insecure-localhost", "--start-maximized");
driver = new ChromeDriver(chromeOptions);
} else if ("htmlunit-firefox".equals(browser)) {
final HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45);
htmlUnitDriver.setJavascriptEnabled(true);
driver = htmlUnitDriver;
} else if ("htmlunit-ie11".equals(browser)) {
final HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.INTERNET_EXPLORER);
htmlUnitDriver.setJavascriptEnabled(true);
driver = htmlUnitDriver;
} else if ("htmlunit-edge".equals(browser)) {
final HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.EDGE);
htmlUnitDriver.setJavascriptEnabled(true);
driver = htmlUnitDriver;
} else if ("htmlunit-chrome".equals(browser)) {
final HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.CHROME);
htmlUnitDriver.setJavascriptEnabled(true);
driver = htmlUnitDriver;
} else {
fail("No valid browser parameter:" + browser);
}
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
webDriverMap.put(browser, driver);
return driver;
}
use of org.openqa.selenium.chrome.ChromeDriver 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);
}
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class ChromePagePerformanceUtil method getLoadTime.
public double getLoadTime(String endUrl, By by) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, flexibleWait);
driver.navigate().to(endUrl);
if (by != null) {
wait.until(ExpectedConditions.presenceOfElementLocated(by)).click();
}
waitPageToLoad(driver, wait);
setTimer(driver);
return calculateLoadTime();
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class ChromePagePerformanceUtil method getLoadTime.
public double getLoadTime(String endUrl) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, flexibleWait);
driver.navigate().to(endUrl);
waitPageToLoad(driver, wait);
setTimer(driver);
return calculateLoadTime();
}
use of org.openqa.selenium.chrome.ChromeDriver in project selenium_java by sergueik.
the class ProtractorDriver method init.
@Before
public void init() throws MalformedURLException {
log.info("Launching (protractor) in " + browser + "...");
DesiredCapabilities capabilities = null;
if (browser.toLowerCase().equals("firefox")) {
capabilities = capabilitiesFirefox(capabilities);
} else if (browser.toLowerCase().equals("phantomjs")) {
capabilities = capabilitiesPhantomJS(capabilities);
} else if (browser.toLowerCase().equals("chrome")) {
capabilities = capabilitiesChrome(capabilities);
} else if (browser.toLowerCase().equals("iexplore")) {
capabilities = capabilitiesExplorer(capabilities);
} else if (browser.toLowerCase().equals("android")) {
capabilities = capabilitiesAndroid(capabilities);
} else if (browser.toLowerCase().equals("iphone")) {
capabilities = capabilitiesiPhone(capabilities);
} else if (browser.toLowerCase().equals("ipad")) {
capabilities = capabilitiesiPad(capabilities);
}
if (!location.toLowerCase().contains("local")) {
log.info("Running on Selenium Grid: " + location);
driver = new RemoteWebDriver(new URL(location), capabilities);
} else if (browser.toLowerCase().equals("firefox")) {
driver = new FirefoxDriver(capabilities);
} else if (browser.toLowerCase().equals("phantomjs")) {
driver = new PhantomJSDriver(capabilities);
} else if (browser.toLowerCase().equals("chrome")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("iexplore")) {
driver = new InternetExplorerDriver(capabilities);
} else if (browser.toLowerCase().equals("android")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("iphone")) {
driver = new ChromeDriver(capabilities);
} else if (browser.toLowerCase().equals("ipad")) {
driver = new ChromeDriver(capabilities);
}
ngDriver = new NgWebDriver(driver);
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
actions = new Actions(driver);
}
Aggregations