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

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

Introduction

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

Prototype

public FirefoxOptions() 

Source Link

Usage

From source file:objective.taskboard.it.AbstractUIIntegrationTest.java

License:Open Source License

@Before
public final void setupUIIntegrationTest() {

    String driverPath = "drivers/" + getOs() + "/marionette/64bit/geckodriver";

    if (System.getProperty("webdriver.gecko.driver") == null)
        System.setProperty("webdriver.gecko.driver", driverPath);

    if (!new File(driverPath).exists())
        throw new IllegalStateException(
                "To run integration tests, you must run 'mvn clean install' at least once to download gecko driver");

    FirefoxOptions options = new FirefoxOptions();

    options.addPreference("dom.file.createInChild", true);
    options.addPreference("browser.link.open_newwindow", 3);
    options.addPreference("browser.link.open_newwindow.restriction", 2);
    options.addPreference("intl.accept_languages", "en");

    try {/*from  w w  w . ja v a2  s. co m*/
        webDriver = new FirefoxDriver(options);
    } catch (WebDriverException ex) {
        System.err.println("UI Integration Tests Aborted: It wasn't possible to instantiate the WebDriver.");
        System.err.println("You could check if Firefox AND geckodriver are up to date.");
        System.exit(1);
    }
    webDriver.manage().window().setSize(new Dimension(1280, 1080));
}

From source file:org.apache.nutch.protocol.selenium.HttpWebClient.java

License:Apache License

public static WebDriver getDriverForPage(String url, Configuration conf) {
    WebDriver driver = null;/*  w w w  .  jav  a  2s.c  o m*/
    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;
        // case "opera":
        // // This class is provided as a convenience for easily testing the
        // Chrome browser.
        // String operaDriverPath = conf.get("selenium.grid.binary",
        // "/root/operadriver");
        // driver = createOperaWebDriver(operaDriverPath, enableHeadlessMode);
        // 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;
}

From source file:org.apache.nutch.protocol.selenium.HttpWebClient.java

License:Apache License

public static WebDriver createFirefoxWebDriver(String firefoxDriverPath, boolean enableHeadlessMode) {
    System.setProperty("webdriver.gecko.driver", firefoxDriverPath);
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    if (enableHeadlessMode) {
        firefoxOptions.addArguments("--headless");
    }/*from   w  w  w .  ja v  a2  s.co m*/
    WebDriver driver = new FirefoxDriver(firefoxOptions);
    return driver;
}

From source file:org.apache.nutch.protocol.selenium.HttpWebClient.java

License:Apache License

public static RemoteWebDriver createFirefoxRemoteWebDriver(URL seleniumHubUrl, boolean enableHeadlessMode) {
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    if (enableHeadlessMode) {
        firefoxOptions.setHeadless(true);
    }//from   www  . j a v  a2s . c om
    RemoteWebDriver driver = new RemoteWebDriver(seleniumHubUrl, firefoxOptions);
    return driver;
}

From source file:org.apache.nutch.protocol.webdriver.driver.NutchFirefoxDriver.java

License:Apache License

static Capabilities populateProfile(FirefoxProfile profile, Capabilities capabilities) {
    if (capabilities == null) {
        return capabilities;
    }/*from w  w  w . j  ava  2  s  . c o  m*/

    Object rawOptions = capabilities.getCapability(FIREFOX_OPTIONS);
    if (rawOptions == null) {
        rawOptions = capabilities.getCapability(OLD_FIREFOX_OPTIONS);
    }
    if (rawOptions != null && !(rawOptions instanceof FirefoxOptions)) {
        throw new WebDriverException("Firefox option was set, but is not a FirefoxOption: " + rawOptions);
    }
    FirefoxOptions options = (FirefoxOptions) rawOptions;
    if (options == null) {
        options = new FirefoxOptions();
    }
    options.setProfile(profile);

    DesiredCapabilities toReturn = capabilities instanceof DesiredCapabilities
            ? (DesiredCapabilities) capabilities
            : new DesiredCapabilities(capabilities);
    toReturn.setCapability(OLD_FIREFOX_OPTIONS, options);
    toReturn.setCapability(FIREFOX_OPTIONS, options);
    return toReturn;
}

From source file:org.apache.portals.pluto.test.utilities.SimpleTestDriver.java

License:Apache License

/**
 * @throws java.lang.Exception//w  w w  .  j ava2s  . c  o  m
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {

    if (driver == null) {
        loginUrl = System.getProperty("test.server.login.url");
        host = System.getProperty("test.server.host");
        port = System.getProperty("test.server.port");
        username = System.getProperty("test.server.username");
        usernameId = System.getProperty("test.server.username.id");
        password = System.getProperty("test.server.password");
        passwordId = System.getProperty("test.server.password.id");
        browser = System.getProperty("test.browser");
        testContextBase = System.getProperty("test.context.base");
        StringBuilder sb = new StringBuilder();
        sb.append("http://");
        sb.append(host);
        if (port != null && !port.isEmpty()) {
            sb.append(":");
            sb.append(port);
        }
        sb.append("/");
        sb.append(testContextBase);
        baseUrl = sb.toString();
        String str = System.getProperty("test.url.strategy");
        useGeneratedUrl = str.equalsIgnoreCase("generateURLs");
        str = System.getProperty("test.debug");
        debug = str.equalsIgnoreCase("true");
        str = System.getProperty("test.timeout");
        dryrun = Boolean.valueOf(System.getProperty("test.dryrun"));
        timeout = ((str != null) && str.matches("\\d+")) ? Integer.parseInt(str) : 3;
        String wd = System.getProperty("test.browser.webDriver");
        String binary = System.getProperty("test.browser.binary");
        String headlessProperty = System.getProperty("test.browser.headless");
        boolean headless = (((headlessProperty == null) || (headlessProperty.length() == 0)
                || Boolean.valueOf(headlessProperty)));
        String maximizedProperty = System.getProperty("test.browser.maximized");
        boolean maximized = Boolean.valueOf(maximizedProperty);

        System.out.println("before class.");
        System.out.println("   Debug        =" + debug);
        System.out.println("   Dryrun       =" + dryrun);
        System.out.println("   Timeout      =" + timeout);
        System.out.println("   Login URL    =" + loginUrl);
        System.out.println("   Host         =" + host);
        System.out.println("   Port         =" + port);
        System.out.println("   Context      =" + testContextBase);
        System.out.println("   Generate URL =" + useGeneratedUrl);
        System.out.println("   Username     =" + username);
        System.out.println("   UsernameId   =" + usernameId);
        System.out.println("   Password     =" + password);
        System.out.println("   PasswordId   =" + passwordId);
        System.out.println("   Browser      =" + browser);
        System.out.println("   Driver       =" + wd);
        System.out.println("   binary       =" + binary);
        System.out.println("   headless     =" + headless);
        System.out.println("   maximized    =" + maximized);

        if (browser.equalsIgnoreCase("firefox")) {

            System.setProperty("webdriver.gecko.driver", wd);
            FirefoxOptions options = new FirefoxOptions();
            options.setLegacy(true);
            options.setAcceptInsecureCerts(true);

            if ((binary != null) && (binary.length() != 0)) {
                options.setBinary(binary);
            }

            if (headless) {
                options.setHeadless(true);
            }

            driver = new FirefoxDriver(options);

        } else if (browser.equalsIgnoreCase("internetExplorer")) {
            System.setProperty("webdriver.ie.driver", wd);
            driver = new InternetExplorerDriver();
        } else if (browser.equalsIgnoreCase("chrome")) {

            System.setProperty("webdriver.chrome.driver", wd);
            ChromeOptions options = new ChromeOptions();

            if ((binary != null) && (binary.length() > 0)) {
                options.setBinary(binary);
            }

            if (headless) {
                options.addArguments("--headless");
            }

            options.addArguments("--disable-infobars");
            options.setAcceptInsecureCerts(true);

            if (maximized) {
                // The webDriver.manage().window().maximize() feature does not work correctly in headless mode, so set the
                // window size to 1920x1200 (resolution of a 15.4 inch screen).
                options.addArguments("--window-size=1920,1200");
            }

            driver = new ChromeDriver(options);

        } else if (browser.equalsIgnoreCase("phantomjs")) {
            DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
            capabilities.setJavascriptEnabled(true);
            capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, binary);
            driver = new PhantomJSDriver(capabilities);
        } else if (browser.equalsIgnoreCase("htmlUnit")) {
            LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
                    "org.apache.commons.logging.impl.NoOpLog");
            Logger.getLogger("com.gargoylesoftware").setLevel(Level.SEVERE);
            Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.SEVERE);
            driver = new HtmlUnitDriver() {
                @Override
                protected WebClient getWebClient() {
                    WebClient webClient = super.getWebClient();
                    WebClientOptions options = webClient.getOptions();
                    options.setThrowExceptionOnFailingStatusCode(false);
                    options.setThrowExceptionOnScriptError(false);
                    options.setPrintContentOnFailingStatusCode(false);
                    webClient.setCssErrorHandler(new SilentCssErrorHandler());
                    return webClient;
                }
            };
        } else if (browser.equalsIgnoreCase("safari")) {
            driver = new SafariDriver();
        } else {
            throw new Exception("Unsupported browser: " + browser);
        }

        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                driver.quit();
            }
        }));

        if (maximized) {
            driver.manage().window().maximize();
        }

        if (!dryrun) {
            login();
        }
    }
}

From source file:org.apache.zeppelin.WebDriverManager.java

License:Apache License

public static WebDriver getWebDriver() {
    WebDriver driver = null;/*from   w w w.ja  v  a 2 s  . com*/

    if (driver == null) {
        try {
            FirefoxBinary ffox = new FirefoxBinary();
            if ("true".equals(System.getenv("TRAVIS"))) {
                ffox.setEnvironmentProperty("DISPLAY", ":99"); // xvfb is supposed to
                // run with DISPLAY 99
            }
            int firefoxVersion = WebDriverManager.getFirefoxVersion();
            LOG.info("Firefox version " + firefoxVersion + " detected");

            downLoadsDir = FileUtils.getTempDirectory().toString();

            String tempPath = downLoadsDir + "/firefox/";

            downloadGeekoDriver(firefoxVersion, tempPath);

            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.download.folderList", 2);
            profile.setPreference("browser.download.dir", downLoadsDir);
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.closeWhenDone", true);
            profile.setPreference("app.update.auto", false);
            profile.setPreference("app.update.enabled", false);
            profile.setPreference("dom.max_script_run_time", 0);
            profile.setPreference("dom.max_chrome_script_run_time", 0);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                    "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
            profile.setPreference("network.proxy.type", 0);

            System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY, tempPath + "geckodriver");
            System.setProperty(SystemProperty.DRIVER_USE_MARIONETTE, "false");

            FirefoxOptions firefoxOptions = new FirefoxOptions();
            firefoxOptions.setBinary(ffox);
            firefoxOptions.setProfile(profile);
            driver = new FirefoxDriver(firefoxOptions);
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
        }
    }

    if (driver == null) {
        try {
            driver = new ChromeDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
        }
    }

    if (driver == null) {
        try {
            driver = new SafariDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while SafariDriver ", e);
        }
    }

    String url;
    if (System.getenv("url") != null) {
        url = System.getenv("url");
    } else {
        url = "http://localhost:8080";
    }

    long start = System.currentTimeMillis();
    boolean loaded = false;
    driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
    driver.get(url);

    while (System.currentTimeMillis() - start < 60 * 1000) {
        // wait for page load
        try {
            (new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {
                @Override
                public Boolean apply(WebDriver d) {
                    return d.findElement(By.xpath("//i[@uib-tooltip='WebSocket Connected']")).isDisplayed();
                }
            });
            loaded = true;
            break;
        } catch (TimeoutException e) {
            LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
            driver.navigate().to(url);
        }
    }

    if (loaded == false) {
        fail();
    }

    driver.manage().window().maximize();
    return driver;
}

From source file:org.jitsi.meet.test.web.WebParticipantFactory.java

License:Apache License

/**
 * Starts a <tt>WebDriver</tt> instance using default settings.
 * @param options the options to use when creating the driver.
 * @return the <tt>WebDriver</tt> instance.
 *//*w  ww .ja  v  a 2  s .  c  om*/
private WebDriver startWebDriver(WebParticipantOptions options) {
    ParticipantType participantType = options.getParticipantType();
    String version = options.getVersion();
    File browserBinaryAPath = getFile(options, options.getBinary());

    boolean isRemote = options.isRemote();

    // by default we load chrome, but we can load safari or firefox
    if (participantType.isFirefox()) {
        FirefoxDriverManager.getInstance().setup();

        if (browserBinaryAPath != null && (browserBinaryAPath.exists() || isRemote)) {
            System.setProperty("webdriver.firefox.bin", browserBinaryAPath.getAbsolutePath());
        }

        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("media.navigator.permission.disabled", true);
        // Enables tcp in firefox, disabled by default in 44
        profile.setPreference("media.peerconnection.ice.tcp", true);
        profile.setPreference("media.navigator.streams.fake", true);
        profile.setAcceptUntrustedCertificates(true);

        profile.setPreference("webdriver.log.file",
                FailureListener.createLogsFolder() + "/firefox-js-console-" + options.getName() + ".log");

        System.setProperty("webdriver.firefox.logfile",
                FailureListener.createLogsFolder() + "/firefox-console-" + options.getName() + ".log");

        if (isRemote) {
            FirefoxOptions ffOptions = new FirefoxOptions();
            ffOptions.setProfile(profile);

            if (version != null && version.length() > 0) {
                ffOptions.setCapability(CapabilityType.VERSION, version);
            }

            return new RemoteWebDriver(options.getRemoteDriverAddress(), ffOptions);
        }

        return new FirefoxDriver(new FirefoxOptions().setProfile(profile));
    } else if (participantType == ParticipantType.safari) {
        // You must enable the 'Allow Remote Automation' option in
        // Safari's Develop menu to control Safari via WebDriver.
        // In Safari->Preferences->Websites, select Camera,
        // and select Allow for "When visiting other websites"
        if (isRemote) {
            return new RemoteWebDriver(options.getRemoteDriverAddress(), new SafariOptions());
        }
        return new SafariDriver();
    } else if (participantType == ParticipantType.edge) {
        InternetExplorerDriverManager.getInstance().setup();

        InternetExplorerOptions ieOptions = new InternetExplorerOptions();
        ieOptions.ignoreZoomSettings();

        System.setProperty("webdriver.ie.driver.silent", "true");

        return new InternetExplorerDriver(ieOptions);
    } else {
        ChromeDriverManager.getInstance().setup();

        System.setProperty("webdriver.chrome.verboseLogging", "true");
        System.setProperty("webdriver.chrome.logfile",
                FailureListener.createLogsFolder() + "/chrome-console-" + options.getName() + ".log");

        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);

        final ChromeOptions ops = new ChromeOptions();
        ops.addArguments("use-fake-ui-for-media-stream");
        ops.addArguments("use-fake-device-for-media-stream");
        ops.addArguments("disable-plugins");
        ops.addArguments("mute-audio");
        ops.addArguments("disable-infobars");
        // Since chrome v66 there are new autoplay policies, which broke
        // shared video tests, disable no-user-gesture to make it work
        ops.addArguments("autoplay-policy=no-user-gesture-required");

        if (options.getChromeExtensionId() != null) {
            try {
                ops.addExtensions(downloadExtension(options.getChromeExtensionId()));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        ops.addArguments("auto-select-desktop-capture-source=Entire screen");

        ops.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

        if (options.isChromeSandboxDisabled()) {
            ops.addArguments("no-sandbox");
            ops.addArguments("disable-setuid-sandbox");
        }

        if (options.isHeadless()) {
            ops.addArguments("headless");
            ops.addArguments("window-size=1200x600");
        }

        // starting version 46 we see crashes of chrome GPU process when
        // running in headless mode
        // which leaves the browser opened and selenium hang forever.
        // There are reports that in older version crashes like that will
        // fallback to software graphics, we try to disable gpu for now
        ops.addArguments("disable-gpu");

        if (browserBinaryAPath != null && (browserBinaryAPath.exists() || isRemote)) {
            ops.setBinary(browserBinaryAPath.getAbsolutePath());
        }

        File uplinkFile = getFile(options, options.getUplink());
        if (uplinkFile != null) {
            ops.addArguments("uplink=" + uplinkFile.getAbsolutePath());
        }

        File downlinkFile = getFile(options, options.getDownlink());
        if (downlinkFile != null) {
            ops.addArguments("downlink=" + downlinkFile.getAbsolutePath());
        }

        String profileDirectory = options.getProfileDirectory();
        if (profileDirectory != null && profileDirectory != "") {
            ops.addArguments("user-data-dir=" + profileDirectory);
        }

        File fakeStreamAudioFile = getFile(options, options.getFakeStreamAudioFile());
        if (fakeStreamAudioFile != null) {
            ops.addArguments("use-file-for-fake-audio-capture=" + fakeStreamAudioFile.getAbsolutePath());
        }

        File fakeStreamVideoFile = getFile(options, options.getFakeStreamVideoFile());
        if (fakeStreamVideoFile != null) {
            ops.addArguments("use-file-for-fake-video-capture=" + fakeStreamVideoFile.getAbsolutePath());
        }

        //ops.addArguments("vmodule=\"*media/*=3,*turn*=3\"");
        ops.addArguments("enable-logging");
        ops.addArguments("vmodule=*=3");

        if (isRemote) {
            if (version != null && version.length() > 0) {
                ops.setCapability(CapabilityType.VERSION, version);
            }

            return new RemoteWebDriver(options.getRemoteDriverAddress(), ops);
        }

        try {
            final ExecutorService pool = Executors.newFixedThreadPool(1);
            // we will retry four times for 1 minute to obtain
            // the chrome driver, on headless environments chrome hangs
            // and we wait forever
            for (int i = 0; i < 2; i++) {
                Future<ChromeDriver> future = null;
                try {
                    future = pool.submit(() -> {
                        long start = System.currentTimeMillis();
                        ChromeDriver resDr = new ChromeDriver(ops);
                        TestUtils.print(
                                "ChromeDriver created for:" + (System.currentTimeMillis() - start) + " ms.");
                        return resDr;
                    });

                    ChromeDriver res = future.get(2, TimeUnit.MINUTES);
                    if (res != null)
                        return res;
                } catch (TimeoutException te) {
                    // cancel current task
                    future.cancel(true);

                    TestUtils.print("Timeout waiting for " + "chrome instance! We will retry now, this was our"
                            + "attempt " + i);
                }

            }
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

        // keep the old code
        TestUtils.print("Just create ChromeDriver, may hang!");
        return new ChromeDriver(ops);
    }
}

From source file:org.kitodo.selenium.testframework.Browser.java

License:Open Source License

private static void provideGeckoDriver() throws IOException {
    String driverFileName = "geckodriver";
    if (SystemUtils.IS_OS_WINDOWS) {
        driverFileName = driverFileName.concat(".exe");
    }/*from w ww.j av  a  2 s  .com*/
    File driverFile = new File(DRIVER_DIR + driverFileName);
    if (!driverFile.exists()) {
        WebDriverProvider.provideGeckoDriver(GECKO_DRIVER_VERSION, DOWNLOAD_DIR, DRIVER_DIR);
    }

    FirefoxProfile profile = new FirefoxProfile();
    profile.setAssumeUntrustedCertificateIssuer(false);
    profile.setPreference("browser.helperApps.alwaysAsk.force", false);
    profile.setPreference("browser.download.dir", DOWNLOAD_DIR);

    FirefoxOptions options = new FirefoxOptions();
    options.setProfile(profile);

    webDriver = new FirefoxDriver(options);
}

From source file:org.structr.web.frontend.selenium.SeleniumTest.java

License:Open Source License

@Before
public void startDriver() {

    switch (activeBrowser) {

    case FIREFOX:

        System.setProperty("webdriver.gecko.driver", getBrowserDriverLocation(activeBrowser));

        final FirefoxOptions firefoxOptions = new FirefoxOptions();
        firefoxOptions.setHeadless(true);

        driver = new FirefoxDriver(firefoxOptions);

        break;/*  w w w .  jav a  2 s  .co  m*/

    case CHROME:

        System.setProperty("webdriver.chrome.driver", getBrowserDriverLocation(activeBrowser));
        System.setProperty("webdriver.chrome.logfile", "/tmp/chromedriver.log");
        System.setProperty("webdriver.chrome.verboseLogging", "true");

        final ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setHeadless(true);

        driver = new ChromeDriver(chromeOptions);

        break;

    case NONE:

        // Don't create a driver in main thread, useful for parallel testing
        break;
    }
}