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(Capabilities source) 

Source Link

Usage

From source file:org.musetest.selenium.providers.GeckoDriverProvider.java

License:Open Source License

@Override
public WebDriver getDriver(SeleniumBrowserCapabilities capabilities, MuseExecutionContext context) {
    if (getOs() != null && !(OperatingSystem.get().equals(getOs())))
        return null; // this provider is not for the current OS

    if (!capabilities.getName().equals(BrowserType.FIREFOX))
        return null;

    File path = getDriverLocation(context);
    if (path == null) {
        context.raiseEvent(MessageEventType.create(
                "GeckoDriverProvider would try to satisfy request for Firefox browser, but it was not configured with a path to the driver"));
        return null;
    }//from  ww w . jav a2s .  c o  m

    if (!(path.exists())) {
        context.raiseEvent(MessageEventType.create(
                "GeckoDriverProvider would try to satisfy request for Firefox browser, but the configured path does not exist: "
                        + path.getAbsolutePath()));
        return null;
    }

    synchronized (GeckoDriverProvider.class) {
        System.setProperty("webdriver.gecko.driver", path.getAbsolutePath());
        DesiredCapabilities selenium_capabilities = DesiredCapabilities.firefox();
        if (capabilities.getVersion() != null && capabilities.getVersion().length() > 0)
            selenium_capabilities.setVersion(capabilities.getVersion());
        if (capabilities.getPlatform() != null && capabilities.getPlatform().length() > 0)
            selenium_capabilities.setPlatform(Platform.fromString(capabilities.getPlatform()));
        selenium_capabilities.setCapability("marionette", true);
        FirefoxOptions options = new FirefoxOptions(selenium_capabilities);
        if (getArguments() != null)
            options.addArguments(getArguments());
        return new FirefoxDriver(options);
    }
}