Example usage for org.openqa.selenium.firefox FirefoxBinary FirefoxBinary

List of usage examples for org.openqa.selenium.firefox FirefoxBinary FirefoxBinary

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxBinary FirefoxBinary.

Prototype

public FirefoxBinary() 

Source Link

Usage

From source file:plugins.KerberosSsoTest.java

License:Open Source License

private FirefoxDriver getNegotiatingFirefox(KerberosContainer kdc, String tokenCache) {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAlwaysLoadNoFocusLib(true);
    // Allow auth negotiation for jenkins under test
    profile.setPreference("network.negotiate-auth.trusted-uris", jenkins.url.toExternalForm());
    profile.setPreference("network.negotiate-auth.delegation-uris", jenkins.url.toExternalForm());
    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("tracelog").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);
    }/*from  w  ww  .  j a  v a 2  s .co  m*/
    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;
}