Java Code Examples for org.openqa.selenium.remote.DesiredCapabilities.firefox()

The following are Jave code examples for showing how to use firefox() of the org.openqa.selenium.remote.DesiredCapabilities class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 8 votes
public static WebDriver getFirefoxDriver()
            throws Exception
	{
        baseDir = new File(".").getPath();
        System.out.println("******** " + baseDir);

        String path = "src/test/resources/geckodriver";
        System.out.println("******** " + path);
		System.setProperty("webdriver.gecko.driver", path);

        DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
		capabilities.setCapability("marionette", true);
        capabilities.setCapability("networkConnectionEnabled", true);
        capabilities.setCapability("browserConnectionEnabled", true);


        WebDriver driver = new RemoteWebDriver(
                new URL("http://localhost:4444"),
                capabilities);

//		WebDriver driver = new MarionetteDriver(capabilities);

		return driver;
	}
 
Example 2
Project: QA_Begin   File: TestContactDoq.java   Source Code and License Vote up 6 votes
@Before
public void setUpTest(){

    System.setProperty("webdriver.gecko.driver", "C:\\webdriver\\geckodriver-v0.11.1-win64\\geckodriver.exe");
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    dc.setCapability("marionette", true);
    driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("http://www.doqconsulting.com.br/#contact");
}
 
Example 3
Project: testing_security_development_enterprise_systems   File: SeleniumTestBase.java   Source Code and License Vote up 6 votes
private static WebDriver getFirefoxDriver(){
    /*
        Need to have an updated Firefox, but also need
        to download and put the geckodriver in your own home dir.
        See:

        https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
        https://github.com/mozilla/geckodriver/releases

        However, drivers for FireFox have been often unstable.
        Therefore, I do recommend to use Chrome instead
     */

    setupDriverExecutable("geckodriver", "webdriver.gecko.driver");

    DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
    desiredCapabilities.setCapability("marionette", true);
    desiredCapabilities.setJavascriptEnabled(true);

    return  new FirefoxDriver(desiredCapabilities);
}
 
Example 4
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 6 votes
public static WebDriver getFirefoxDriver()
            throws Exception
	{
        baseDir = new File(".").getPath();
        System.out.println("******** " + baseDir);

        String path = "src/test/resources/geckodriver";
        System.out.println("******** " + path);
		System.setProperty("webdriver.gecko.driver", path);

        DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
		capabilities.setCapability("marionette", true);
        capabilities.setCapability("networkConnectionEnabled", true);
        capabilities.setCapability("browserConnectionEnabled", true);


        WebDriver driver = new RemoteWebDriver(
                new URL("http://localhost:4444"),
                capabilities);

//		WebDriver driver = new MarionetteDriver(capabilities);

		return driver;
	}
 
Example 5
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 6 votes
public static WebDriver getFirefoxDriver()
            throws Exception
	{
        baseDir = new File(".").getPath();
        System.out.println("******** " + baseDir);

        String path = "src/test/resources/geckodriver";
        System.out.println("******** " + path);
		System.setProperty("webdriver.gecko.driver", path);

        DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
		capabilities.setCapability("marionette", true);
        capabilities.setCapability("networkConnectionEnabled", true);
        capabilities.setCapability("browserConnectionEnabled", true);


        WebDriver driver = new RemoteWebDriver(
                new URL("http://localhost:4444"),
                capabilities);

//		WebDriver driver = new MarionetteDriver(capabilities);

		return driver;
	}
 
Example 6
Project: phoenix.webui.framework   File: CapabilityConfig.java   Source Code and License Vote up 5 votes
/**
 * 火狐浏览器配置
 */
private void firefox()
{
	DesiredCapabilities capability = DesiredCapabilities.firefox();
	capability.setCapability("marionette", true);
	engineCapMap.put(DRIVER_FIREFOX, capability);
}
 
Example 7
Project: functional-programming-selenium-examples   File: Firefox.java   Source Code and License Vote up 5 votes
@Override
public WebDriver getWebDriver()
{
	System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver.v0.11.1.mac");
	DesiredCapabilities capabilities=DesiredCapabilities.firefox();
	WebDriver driver = new FirefoxDriver(capabilities);
       return driver;
}
 
Example 8
Project: NoraUi   File: DriverFactory.java   Source Code and License Vote up 5 votes
/**
 * Generates a firefox webdriver.
 *
 * @return
 *         A firefox webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generateFirefoxDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.FIREFOX);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Firefox driver ({}) ...", pathWebdriver);

    System.setProperty(Driver.FIREFOX.getDriverName(), pathWebdriver);

    final FirefoxOptions firefoxOptions = new FirefoxOptions();
    final FirefoxBinary firefoxBinary = new FirefoxBinary();

    final DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }

    if (Context.isHeadless()) {
        firefoxBinary.addCommandLineOptions("--headless");
        firefoxOptions.setBinary(firefoxBinary);
    }
    firefoxOptions.setLogLevel(Level.OFF);

    capabilities.setCapability(FirefoxOptions.FIREFOX_OPTIONS, firefoxOptions);

    return new FirefoxDriver(capabilities);
}
 
Example 9
Project: zucchini   File: SeleniumDriver.java   Source Code and License Vote up 5 votes
private static WebDriver createFireFoxDriver() {
	FirefoxProfile firefoxProfile = new FirefoxProfile();
	firefoxProfile.setEnableNativeEvents(false);
	firefoxProfile.setAcceptUntrustedCertificates(true);
	firefoxProfile.setPreference("layers.acceleration.disabled", true);

	DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
	desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

	return new FirefoxDriver(desiredCapabilities);
}
 
Example 10
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 5 votes
public static WebDriver getFirefoxDriver(String pathToFirefoxExecutable)
{
       String path = "src/test/resources/geckodriver";
	System.setProperty("webdriver.gecko.driver", path);
	System.setProperty("webdriver.firefox.bin", pathToFirefoxExecutable);

	DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
       capabilities.setCapability("marionette", true);
       capabilities.setCapability("networkConnectionEnabled", true);
       capabilities.setCapability("browserConnectionEnabled", true);

	WebDriver driver = new MarionetteDriver(capabilities);

	return driver;
}
 
Example 11
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 5 votes
public static WebDriver getFirefoxDriver(String pathToFirefoxExecutable)
{
       String path = "src/test/resources/geckodriver";
	System.setProperty("webdriver.gecko.driver", path);
	System.setProperty("webdriver.firefox.bin", pathToFirefoxExecutable);

	DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
       capabilities.setCapability("marionette", true);
       capabilities.setCapability("networkConnectionEnabled", true);
       capabilities.setCapability("browserConnectionEnabled", true);

	WebDriver driver = new MarionetteDriver(capabilities);

	return driver;
}
 
Example 12
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License Vote up 5 votes
public static WebDriver getFirefoxDriver(String pathToFirefoxExecutable)
{
       String path = "src/test/resources/geckodriver";
	System.setProperty("webdriver.gecko.driver", path);
	System.setProperty("webdriver.firefox.bin", pathToFirefoxExecutable);

	DesiredCapabilities capabilities =  DesiredCapabilities.firefox();
       capabilities.setCapability("marionette", true);
       capabilities.setCapability("networkConnectionEnabled", true);
       capabilities.setCapability("browserConnectionEnabled", true);

	WebDriver driver = new MarionetteDriver(capabilities);

	return driver;
}
 
Example 13
Project: teasy   File: DriverUtils.java   Source Code and License Vote up 4 votes
private static DesiredCapabilities getFireFoxDesiredCapabilities(Settings settings) {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setCapability(FirefoxDriver.PROFILE, getFirefoxProfile(settings));
    return capabilities;
}
 
Example 14
Project: SWET   File: BrowserDriver.java   Source Code and License Vote up 4 votes
@SuppressWarnings("deprecation")
private static DesiredCapabilities capabilitiesFirefox() {

	final String geckoDriverPath = (applicationGeckoDriverPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/java/selenium/geckodriver.exe" : "/var/run/geckodriver"
			: applicationGeckoDriverPath;
	// firefox.browser.path
	final String firefoxBrowserPath = (applicationFirefoxBrowserPath == null)
			? osName.toLowerCase().startsWith("windows")
					? "c:/Program Files (x86)/Mozilla Firefox/firefox.exe"
					: osName.toLowerCase().startsWith("mac")
							? "/Applications/Firefox.app/Contents/MacOS/firefox.bin"
							: "/usr/bin/firefox/firefox"
			: applicationFirefoxBrowserPath;
	System.setProperty("webdriver.gecko.driver",
			new File(geckoDriverPath).getAbsolutePath());
	System.setProperty("webdriver.firefox.bin",
			new File(firefoxBrowserPath).getAbsolutePath());
	System.setProperty("webdriver.reap_profile", "false");
	DesiredCapabilities capabilities = DesiredCapabilities.firefox();

	// TODO: switch to Selenium 3.X+
	/*
	FirefoxOptions firefoxOptions = new FirefoxOptions();
	firefoxOptions.setBinary(new File(firefoxBrowserPath).getAbsolutePath());
	
	capabilities.setCapability("moz:firefoxOptions", firefoxOptions);
	*/
	capabilities.setCapability("firefox_binary",
			new File(firefoxBrowserPath).getAbsolutePath());

	capabilities.setCapability("marionette", false);
	FirefoxProfile profile = new FirefoxProfile();
	// no longer exists in Selenium
	// profile.setEnableNativeEvents(true);
	profile.setAcceptUntrustedCertificates(true);
	profile.setAssumeUntrustedCertificateIssuer(false);

	// Disable Firefox Auto-Updating
	profile.setPreference("app.update.auto", false);
	profile.setPreference("app.update.enabled", false);

	capabilities.setCapability(FirefoxDriver.PROFILE, profile);
	capabilities.setCapability("elementScrollBehavior", 1);
	capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
	return capabilities;
}
 
Example 15
Project: daf-cacher   File: Browser.java   Source Code and License Vote up 4 votes
public Builder firefox() {
    this.browserCaps = DesiredCapabilities.firefox();
    return this;
}