use of com.opera.core.systems.OperaDriver in project Ebselen by Ardesco.
the class EbselenCore method setBrowser.
/**
* Set the driver type based upon settings scraped from Env.properties
* run function to get release number of website being tested
*
* @param driverObject - object to instantiate
* @return WebDriver
*/
public WebDriver setBrowser(WebDriver driverObject) {
try {
switch(browserDetails.getBrowser()) {
case FIREFOX:
driverObject = new FirefoxDriver(generateFirefoxProfile());
logger.debug("Using FIREFOX Driver...");
break;
case IE6:
case IE7:
case IE8:
case IE9:
driverObject = new InternetExplorerDriver();
logger.debug("Using INTERNET EXPLORER Driver...");
break;
case GOOGLECHROME:
System.setProperty("webdriver.chrome.driver", settings.chromeDriverLocation());
driverObject = new ChromeDriver();
logger.debug("Using GOOGLECHROME Driver...");
break;
case HTMLUNIT:
driverObject = new HtmlUnitDriver(setHTMLUnitCapabilities(browserDetails.getHTMLUnitEmulation()));
logger.debug("Using HTMLUNIT Driver...");
break;
case SAFARI:
//FUTURE
break;
case OPERA:
driverObject = new OperaDriver();
logger.debug("Using Opera Driver...");
break;
case IPHONE:
driverObject = new IPhoneDriver();
logger.debug("Using IPhone Driver...");
break;
case ANDROID:
driverObject = new AndroidDriver();
logger.debug("Using Android Driver...");
break;
}
getReleaseVersion();
} catch (Exception x) {
logger.error("Error in EbselenCore.setBrowser: {}", x.getMessage());
return driverObject;
}
return driverObject;
}
use of com.opera.core.systems.OperaDriver in project nutch by apache.
the class HttpWebClient method getDriverForPage.
public static WebDriver getDriverForPage(String url, Configuration conf) {
WebDriver driver = null;
DesiredCapabilities capabilities = null;
long pageLoadWait = conf.getLong("page.load.delay", 3);
try {
String driverType = conf.get("selenium.driver", "firefox");
switch(driverType) {
case "firefox":
String allowedHost = conf.get("selenium.firefox.allowed.hosts", "localhost");
long firefoxBinaryTimeout = conf.getLong("selenium.firefox.binary.timeout", 45);
boolean enableFlashPlayer = conf.getBoolean("selenium.firefox.enable.flash", false);
int loadImage = conf.getInt("selenium.firefox.load.image", 1);
int loadStylesheet = conf.getInt("selenium.firefox.load.stylesheet", 1);
FirefoxProfile profile = new FirefoxProfile();
FirefoxBinary binary = new FirefoxBinary();
profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, allowedHost);
profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", enableFlashPlayer);
profile.setPreference("permissions.default.stylesheet", loadStylesheet);
profile.setPreference("permissions.default.image", loadImage);
binary.setTimeout(TimeUnit.SECONDS.toMillis(firefoxBinaryTimeout));
driver = new FirefoxDriver(binary, profile);
break;
case "chrome":
driver = new ChromeDriver();
break;
case "safari":
driver = new SafariDriver();
break;
case "opera":
driver = new OperaDriver();
break;
case "phantomjs":
driver = new PhantomJSDriver();
break;
case "remote":
String seleniumHubHost = conf.get("selenium.hub.host", "localhost");
int seleniumHubPort = Integer.parseInt(conf.get("selenium.hub.port", "4444"));
String seleniumHubPath = conf.get("selenium.hub.path", "/wd/hub");
String seleniumHubProtocol = conf.get("selenium.hub.protocol", "http");
String seleniumGridDriver = conf.get("selenium.grid.driver", "firefox");
String seleniumGridBinary = conf.get("selenium.grid.binary");
switch(seleniumGridDriver) {
case "firefox":
capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("firefox_binary", seleniumGridBinary);
System.setProperty("webdriver.reap_profile", "false");
driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), capabilities);
break;
case "phantomjs":
capabilities = DesiredCapabilities.phantomjs();
capabilities.setBrowserName("phantomjs");
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, seleniumGridBinary);
driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), capabilities);
break;
default:
LOG.error("The Selenium Grid WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);
driver = new RemoteWebDriver(new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath), DesiredCapabilities.firefox());
break;
}
break;
default:
LOG.error("The Selenium WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);
driver = new FirefoxDriver();
break;
}
LOG.debug("Selenium {} WebDriver selected.", driverType);
driver.manage().timeouts().pageLoadTimeout(pageLoadWait, TimeUnit.SECONDS);
driver.get(url);
} catch (Exception e) {
if (e instanceof TimeoutException) {
LOG.debug("Selenium WebDriver: Timeout Exception: Capturing whatever loaded so far...");
return driver;
}
cleanUpDriver(driver);
throw new RuntimeException(e);
}
return driver;
}
Aggregations