Example usage for org.openqa.selenium.firefox FirefoxProfile getIntegerPreference

List of usage examples for org.openqa.selenium.firefox FirefoxProfile getIntegerPreference

Introduction

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

Prototype

public int getIntegerPreference(String key, int defaultValue) 

Source Link

Usage

From source file:com.seleniumtests.ut.browserfactory.TestFirefoxCapabilitiesFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultFirefoxCapabilities() {

    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Mockito.when(config.isSetAcceptUntrustedCertificates()).thenReturn(true);
    Mockito.when(config.isSetAssumeUntrustedCertificateIssuer()).thenReturn(true);

    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "firefox");
    Assert.assertEquals(capa.getCapability(FirefoxDriver.MARIONETTE), false);

    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);

    // check profile
    Assert.assertTrue(profile.getBooleanPreference("webdriver_accept_untrusted_certs", false));
    Assert.assertTrue(profile.getBooleanPreference("webdriver_assume_untrusted_issuer", false));
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.QueryInterface", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.frameElement.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(//from   w w  w .  j  ava 2 s.  c  o  m
            profile.getStringPreference("capability.policy.default.HTMLDocument.compatMode.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Document.compatMode.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getIntegerPreference("dom.max_chrome_script_run_time", 100), 0);
    Assert.assertEquals(profile.getIntegerPreference("dom.max_script_run_time", 100), 0);
}

From source file:com.seleniumtests.ut.browserfactory.TestFirefoxCapabilitiesFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateFirefoxCapabilitiesOverrideDownloadDir() {

    Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");

    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();

    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);

    // check profile
    Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "/home/download");
    Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 2);
    Assert.assertEquals(profile.getBooleanPreference("browser.download.manager.showWhenStarting", true), false);
    Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""),
            "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");
}

From source file:com.seleniumtests.ut.browserfactory.TestMarionetteCapabilitiesFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultMarionetteCapabilities() {

    Mockito.when(config.getMode()).thenReturn(DriverMode.LOCAL);
    Mockito.when(config.isSetAcceptUntrustedCertificates()).thenReturn(true);
    Mockito.when(config.isSetAssumeUntrustedCertificateIssuer()).thenReturn(true);

    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getCapability(CapabilityType.BROWSER_NAME), "firefox");
    Assert.assertEquals(capa.getCapability(FirefoxDriver.MARIONETTE), true);

    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);

    // check profile
    Assert.assertTrue(profile.getBooleanPreference("webdriver_accept_untrusted_certs", false));
    Assert.assertTrue(profile.getBooleanPreference("webdriver_assume_untrusted_issuer", false));
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.QueryInterface", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Window.frameElement.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(// w ww. j  a va2 s.c om
            profile.getStringPreference("capability.policy.default.HTMLDocument.compatMode.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getStringPreference("capability.policy.default.Document.compatMode.get", ""),
            FirefoxCapabilitiesFactory.ALL_ACCESS);
    Assert.assertEquals(profile.getIntegerPreference("dom.max_chrome_script_run_time", 100), 0);
    Assert.assertEquals(profile.getIntegerPreference("dom.max_script_run_time", 100), 0);
}

From source file:com.seleniumtests.ut.browserfactory.TestMarionetteCapabilitiesFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateMarionetteCapabilitiesOverrideDownloadDir() {

    Mockito.when(config.getBrowserDownloadDir()).thenReturn("/home/download");

    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();

    FirefoxProfile profile = (FirefoxProfile) capa.getCapability(FirefoxDriver.PROFILE);

    // check profile
    Assert.assertEquals(profile.getStringPreference("browser.download.dir", ""), "/home/download");
    Assert.assertEquals(profile.getIntegerPreference("browser.download.folderList", 0), 2);
    Assert.assertEquals(profile.getBooleanPreference("browser.download.manager.showWhenStarting", true), false);
    Assert.assertEquals(profile.getStringPreference("browser.helperApps.neverAsk.saveToDisk", ""),
            "application/octet-stream,text/plain,application/pdf,application/zip,text/csv,text/html");
}

From source file:org.testeditor.fixture.web.CapabilityIntegrationtest.java

License:Open Source License

private void readCapabilitiesFromProfile(WebDriverFixture fixture) {
    WebDriver driver = fixture.getDriver();
    Capabilities cap = ((RemoteWebDriver) driver).getCapabilities();
    String profilePath = (String) cap.getCapability("moz:profile");
    logger.debug("Firefox Preferences read successfully");
    FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
    proxyHttp = profile.getStringPreference("network.proxy.http", "");
    logger.debug("Firefox Preference proxy HTTP = {} read successfully", proxyHttp);
    proxyHttpPort = profile.getIntegerPreference("network.proxy.http_port", 0);
    logger.debug("Firefox Preference proxy HTTP port = {} read successfully", proxyHttpPort);
    proxySsl = profile.getStringPreference("network.proxy.ssl", "");
    logger.debug("Firefox Preference proxy SSL = {}  read successfully", proxySsl);
    proxySslPort = profile.getIntegerPreference("network.proxy.ssl_port", 0);
    logger.debug("Firefox Preference proxy SSL port = {}  read successfully", proxySslPort);
    proxyType = profile.getIntegerPreference("network.proxy.type", 0);
    logger.debug("Firefox Preference proxy type = {}  read successfully", proxyType);
    logger.debug(" ######## End of Test readCapabilitiesFromProfile ########");
}