use of org.openqa.selenium.firefox.FirefoxOptions in project wcomponents by BorderTech.
the class FirefoxWebDriverType method getDriverImplementation.
/**
* {@inheritDoc}.
*/
@Override
public FirefoxDriver getDriverImplementation() {
WebDriverManager.getInstance(DriverManagerType.FIREFOX).setup();
FirefoxOptions options = new FirefoxOptions(getCapabilities());
FirefoxBinary binary = getFirefoxBinary();
FirefoxProfile profile = getFirefoxProfile();
if (profile != null) {
// it gets angry if you give it a null profile
options.setProfile(profile);
}
// options.setHeadless(true);
options.setBinary(binary);
return new FirefoxDriver(options);
}
use of org.openqa.selenium.firefox.FirefoxOptions in project nutch by apache.
the class HttpWebClient method getDriverForPage.
public static WebDriver getDriverForPage(String url, Configuration conf) {
WebDriver driver = null;
long pageLoadWait = conf.getLong("page.load.delay", 3);
try {
String driverType = conf.get("selenium.driver", "firefox");
boolean enableHeadlessMode = conf.getBoolean("selenium.enable.headless", false);
switch(driverType) {
case "firefox":
String geckoDriverPath = conf.get("selenium.grid.binary", "/root/geckodriver");
driver = createFirefoxWebDriver(geckoDriverPath, enableHeadlessMode);
break;
case "chrome":
String chromeDriverPath = conf.get("selenium.grid.binary", "/root/chromedriver");
driver = createChromeWebDriver(chromeDriverPath, enableHeadlessMode);
break;
// 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");
URL seleniumHubUrl = new URL(seleniumHubProtocol, seleniumHubHost, seleniumHubPort, seleniumHubPath);
String seleniumGridDriver = conf.get("selenium.grid.driver", "firefox");
switch(seleniumGridDriver) {
case "firefox":
driver = createFirefoxRemoteWebDriver(seleniumHubUrl, enableHeadlessMode);
break;
case "chrome":
driver = createChromeRemoteWebDriver(seleniumHubUrl, enableHeadlessMode);
break;
case "random":
driver = createRandomRemoteWebDriver(seleniumHubUrl, enableHeadlessMode);
break;
default:
LOG.error("The Selenium Grid WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);
driver = createDefaultRemoteWebDriver(seleniumHubUrl, enableHeadlessMode);
break;
}
break;
default:
LOG.error("The Selenium WebDriver choice {} is not available... defaulting to FirefoxDriver().", driverType);
FirefoxOptions options = new FirefoxOptions();
driver = new FirefoxDriver(options);
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.error("Selenium WebDriver: Timeout Exception: Capturing whatever loaded so far...");
return driver;
} else {
LOG.error(e.toString());
}
cleanUpDriver(driver);
throw new RuntimeException(e);
}
return driver;
}
use of org.openqa.selenium.firefox.FirefoxOptions in project nutch by apache.
the class HttpWebClient method createFirefoxWebDriver.
public static WebDriver createFirefoxWebDriver(String firefoxDriverPath, boolean enableHeadlessMode) {
System.setProperty("webdriver.gecko.driver", firefoxDriverPath);
FirefoxOptions firefoxOptions = new FirefoxOptions();
if (enableHeadlessMode) {
firefoxOptions.addArguments("--headless");
}
WebDriver driver = new FirefoxDriver(firefoxOptions);
return driver;
}
use of org.openqa.selenium.firefox.FirefoxOptions in project nutch by apache.
the class HttpWebClient method createFirefoxRemoteWebDriver.
public static RemoteWebDriver createFirefoxRemoteWebDriver(URL seleniumHubUrl, boolean enableHeadlessMode) {
FirefoxOptions firefoxOptions = new FirefoxOptions();
if (enableHeadlessMode) {
firefoxOptions.setHeadless(true);
}
RemoteWebDriver driver = new RemoteWebDriver(seleniumHubUrl, firefoxOptions);
return driver;
}
use of org.openqa.selenium.firefox.FirefoxOptions in project drools by kiegroup.
the class FEELShowcaseIT method getFirefoxOptions.
private FirefoxOptions getFirefoxOptions() {
final FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setHeadless(HEADLESS);
firefoxOptions.setProfile(getFirefoxProfile());
return firefoxOptions;
}
Aggregations