use of org.openqa.selenium.firefox.FirefoxBinary 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.FirefoxBinary in project acceptance-test-harness by jenkinsci.
the class KerberosSsoTest method getNegotiatingFirefox.
private FirefoxDriver getNegotiatingFirefox(KerberosContainer kdc, String tokenCache) {
FirefoxProfile profile = new FirefoxProfile();
profile.setAlwaysLoadNoFocusLib(true);
// Allow auth negotiation for jenkins under test
String trustedUris = jenkins.url.toExternalForm();
String jenkins_local_hostname = System.getenv("JENKINS_LOCAL_HOSTNAME");
// if JENKINS_LOCAL_HOSTNAME is set, we add this to FF nego uris
if (jenkins_local_hostname != null && !jenkins_local_hostname.isEmpty()) {
try {
// In the case where JENKINS_LOCAL_HOSTNAME is an IP,
// we need to add its resolved hostname for auth negociation
String hostName = InetAddress.getByName(jenkins_local_hostname).getCanonicalHostName();
trustedUris = trustedUris + ", " + hostName;
} catch (UnknownHostException e) {
e.printStackTrace();
throw new Error(e);
}
}
profile.setPreference("network.negotiate-auth.trusted-uris", trustedUris);
profile.setPreference("network.negotiate-auth.delegation-uris", trustedUris);
FirefoxBinary binary = new FirefoxBinary();
// Inject config and TGT
binary.setEnvironmentProperty("KRB5CCNAME", tokenCache);
binary.setEnvironmentProperty("KRB5_CONFIG", kdc.getKrb5ConfPath());
// Turn debug on
binary.setEnvironmentProperty("KRB5_TRACE", diag.touch("krb5_trace.log").getAbsolutePath());
binary.setEnvironmentProperty("NSPR_LOG_MODULES", "negotiateauth:5");
binary.setEnvironmentProperty("NSPR_LOG_FILE", diag.touch("firefox.nego.log").getAbsolutePath());
String display = FallbackConfig.getBrowserDisplay();
if (display != null) {
binary.setEnvironmentProperty("DISPLAY", display);
}
final FirefoxDriver driver = new FirefoxDriver(binary, profile);
cleaner.addTask(new Statement() {
@Override
public void evaluate() throws Throwable {
try {
driver.quit();
} catch (UnreachableBrowserException ex) {
System.err.println("Browser died already");
ex.printStackTrace();
}
}
@Override
public String toString() {
return "Close Kerberos WebDriver after test";
}
});
return driver;
}
use of org.openqa.selenium.firefox.FirefoxBinary 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.firefox.FirefoxBinary in project selenium_java by sergueik.
the class HeadlessFirefoxSeleniumExample method main.
public static void main(String[] args) {
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
System.setProperty("webdriver.gecko.driver", "/home/sergueik/Downloads/geckodriver");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
try {
driver.get("http://www.google.com");
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
WebElement queryBox = driver.findElement(By.name("q"));
queryBox.sendKeys("headless firefox");
WebElement searchBtn = driver.findElement(By.name("btnK"));
searchBtn.click();
WebElement iresDiv = driver.findElement(By.id("ires"));
iresDiv.findElements(By.tagName("a")).get(0).click();
System.out.println(driver.getPageSource());
} finally {
driver.quit();
}
}
Aggregations