Java 类org.openqa.selenium.firefox.FirefoxProfile 实例源码

项目:willtest    文件:AdBlockerConfigurator.java   
@Override
public void adjustFirefoxProfile(FirefoxProfile firefoxProfile) {
    try {
        URL adBlockerXPIResourceURL = this.getClass().getResource(ADBLOCK_XPI_RESOURCE_PATH);
        if (adBlockerXPIResourceURL != null && new File(adBlockerXPIResourceURL.toURI()).exists()) {
            firefoxProfile.addExtension(new File(adBlockerXPIResourceURL.getFile()));
        } else {
            throw new IllegalStateException("Expected a file called '" + ADBLOCK_XPI_RESOURCE_PATH +
                    "' in classpath root! First try a 'mvn clean install' on your maven project. " +
                    "If it does not help, your maven module is not correctly configured. " +
                    "For configuration details please read the JavaDOC of " + this.getClass().getName() + "!");
        }
    } catch (URISyntaxException e) {
        throw new RuntimeException("Cannot install adblocker extension!", e);
    }
}
项目:alimama    文件:SeleniumUtil.java   
public static void setDesiredCapabilities() {
    logger.info("start init Firefox profile!");
    String plugin = SeleniumUtil.class.getResource("/plugin/killspinners-1.2.1-fx.xpi").getPath();
    try {
        profile = new FirefoxProfile();
        // profile = new ProfilesIni().getProfile("default");
        profile.addExtension(new File(plugin));
        // 鍘绘帀css
        // profile.setPreference("permissions.default.stylesheet", 2);
        // 鍘绘帀鍥剧墖
        // profile.setPreference("permissions.default.image", 2);
        // 鍘绘帀flash
        profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);
        capability = DesiredCapabilities.firefox();
        capability.setCapability("firefox_profile", profile);

    } catch (Exception e) {
        logger.error("init firefox plugin(killspinnners) is error! ", e);
    }
    logger.info("init Firefox profile is success!");
}
项目:alimama    文件:SeleniumUtil.java   
public static WebDriver createWebDriver() throws Exception {
    DesiredCapabilities capability = DesiredCapabilities.chrome();
    capability.setJavascriptEnabled(true);
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    // 鍘绘帀css
    // firefoxProfile.setPreference("permissions.default.stylesheet", 2);
    // 鍘绘帀鍥剧墖
    // firefoxProfile.setPreference("permissions.default.image", 2);
    // 鍘绘帀flash
    firefoxProfile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);

    capability.setCapability("firefox_profile", firefoxProfile);
    WebDriver driver = new FirefoxDriver(capability);

    // WebDriver driver = new HtmlUnitDriver();
    // WebDriver driver = new HtmlUnitDriver();
    // 濡傛灉3s鍐呰繕瀹氫綅涓嶅埌鍒欐姏鍑哄紓甯?
    // driver.manage().timeouts().implicitlyWait(IMPLICITLYWAIT,
    // TimeUnit.SECONDS);
    // 椤甸潰鍔犺浇瓒呮椂鏃堕棿璁剧疆涓?5s
    // driver.manage().timeouts().pageLoadTimeout(PAGELOADTIMEOUT,
    // TimeUnit.SECONDS);
    // driver.manage().timeouts().setScriptTimeout(60,TimeUnit.SECONDS);
    return driver;

}
项目:alimama    文件:SeleniumUtil.java   
public static void setDesiredCapabilities() {
    logger.info("start init Firefox profile!");
    String plugin = SeleniumUtil.class.getResource("/plugin/killspinners-1.2.1-fx.xpi").getPath();
    try {
        profile = new FirefoxProfile();
        // profile = new ProfilesIni().getProfile("default");
        //profile.addExtension(new File(plugin));
        // 鍘绘帀css
        // profile.setPreference("permissions.default.stylesheet", 2);
        // 鍘绘帀鍥剧墖
        //profile.setPreference("permissions.default.image", 2);
        // 鍘绘帀flash
        profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);
        //profile.setPreference("--log", "error");

        //FirefoxOptions opts = new FirefoxOptions().setLogLevel(Level.INFO);
        //capability = opts.addTo(DesiredCapabilities.firefox());
        capability = DesiredCapabilities.firefox();
        capability.setCapability("firefox_profile", profile);
        //capability.setCapability("marionette", true);

    } catch (Exception e) {
        logger.error("init firefox plugin(killspinnners) is error! ", e);
    }
    logger.info("init Firefox profile is success!");
}
项目:alimama    文件:SeleniumUtil.java   
public static WebDriver createWebDriver() throws Exception {
    DesiredCapabilities capability = DesiredCapabilities.chrome();
    capability.setJavascriptEnabled(true);
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    // 鍘绘帀css
    // firefoxProfile.setPreference("permissions.default.stylesheet", 2);
    // 鍘绘帀鍥剧墖
    // firefoxProfile.setPreference("permissions.default.image", 2);
    // 鍘绘帀flash
    firefoxProfile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);

    capability.setCapability("firefox_profile", firefoxProfile);
    WebDriver driver = new FirefoxDriver(capability);

    // WebDriver driver = new HtmlUnitDriver();
    // WebDriver driver = new HtmlUnitDriver();
    // 濡傛灉3s鍐呰繕瀹氫綅涓嶅埌鍒欐姏鍑哄紓甯?
    // driver.manage().timeouts().implicitlyWait(IMPLICITLYWAIT,
    // TimeUnit.SECONDS);
    // 椤甸潰鍔犺浇瓒呮椂鏃堕棿璁剧疆涓?5s
    // driver.manage().timeouts().pageLoadTimeout(PAGELOADTIMEOUT,
    // TimeUnit.SECONDS);
    // driver.manage().timeouts().setScriptTimeout(60,TimeUnit.SECONDS);
    return driver;

}
项目:KeywordDrivenAutoTest    文件:Firefox.java   
/**
 * 本地初始化Firefox浏览器driver
 */
public Firefox() {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("acceptSslCerts", false);
    FirefoxBrowserProfile firefoxProfile = new FirefoxBrowserProfile();
    String sProfile = firefoxProfile.getDefaultProfile();
    if (sProfile.equals("")) {
        this.driver = new FirefoxDriver();
    } else {
        try {
            FirefoxProfile profile = new FirefoxProfile(new File(sProfile));
            FirefoxBinary firefoxBinary = new FirefoxBinary(new File(firefoxProfile.getFirefoxBinInstallPath()));
            profile.setAcceptUntrustedCertificates(false);
            this.driver = new FirefoxDriver(firefoxBinary, profile);
        } catch (Exception e) {
            throw new RuntimeException("Failed to start firefox browser,please check!", e);
        }
    }
}
项目:aet    文件:FirefoxWebDriverFactory.java   
@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer)
    throws WorkerException {
  try {
    Proxy proxy = proxyServer.seleniumProxy();
    proxyServer.setCaptureContent(true);
    proxyServer.setCaptureHeaders(true);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    FirefoxProfile fp = getFirefoxProfile();
    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);
    capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

    return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
        requestExecutorFactory
            .createInstance());
  } catch (Exception e) {
    throw new WorkerException(e.getMessage(), e);
  }
}
项目:aet    文件:FirefoxWebDriverFactory.java   
private FirefoxProfile getFirefoxProfile() throws IOException {
  final FirefoxProfile firefoxProfile = FirefoxProfileBuilder.newInstance()
      .withUnstableAndFastLoadStrategy()
      .withLogfilePath(logFilePath)
      .withFlashSwitchedOff()
      .withForcedAliasing()
      .withJavaScriptErrorCollectorPlugin()
      .withDevtoolsStorageEnabled()
      .withAllCookiesAccepted()
      .withRandomPort()
      .withUpdateDisabled()
      .build();
  System.setProperty("webdriver.firefox.logfile", logFilePath);
  System.setProperty("webdriver.load.strategy", "unstable");
  return firefoxProfile;
}
项目:jsflight    文件:SeleniumDriver.java   
private FirefoxProfile createDefaultFirefoxProfile()
{
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.setPreference("nglayout.initialpaint.delay", "0");
    firefoxProfile.setPreference("network.http.pipelining", true);
    firefoxProfile.setPreference("image.animation_mode", "none");
    firefoxProfile.setPreference("layers.acceleration.force-enabled", true);
    firefoxProfile.setPreference("layers.offmainthreadcomposition.enabled", true);
    firefoxProfile.setPreference("browser.sessionstore.interval", 3600000);
    firefoxProfile.setPreference("privacy.trackingprotection.enabled", true);
    firefoxProfile.setPreference("content.notify.interval", 849999);
    firefoxProfile.setPreference("content.notify.backoffcount", 5);
    firefoxProfile.setPreference("network.http.max-connections", 50);
    firefoxProfile.setPreference("network.http.max-connections-per-server", 150);
    firefoxProfile.setPreference("network.http.pipelining.aggressive", false);
    firefoxProfile.setPreference("browser.tabs.animate", false);
    firefoxProfile.setPreference("browser.display.show_image_placeholders", false);
    firefoxProfile.setPreference("browser.cache.use_new_backend", 1);
    firefoxProfile.setPreference("ui.submenuDelay", 0);
    firefoxProfile.setPreference("browser.cache.disk.enable", false);
    firefoxProfile.setPreference("browser.cache.memory.enable", true);
    firefoxProfile.setPreference("browser.cache.memory.capacity", 128000);
    return firefoxProfile;
}
项目:kc-rice    文件:JiraIssueCreation.java   
private void login() throws InterruptedException {DesiredCapabilities capabilities = new DesiredCapabilities();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setEnableNativeEvents(false);
    capabilities.setCapability(FirefoxDriver.PROFILE, profile);

    driver = new FirefoxDriver(capabilities);
    driver.manage().timeouts().implicitlyWait(WebDriverUtils.configuredImplicityWait(), TimeUnit.SECONDS);
    driver.get(jiraBase + "/secure/Dashboard.jspa");

    WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.className("login-link"),
            this.getClass().toString()).click();

    // CAS
    WebDriverUtils.waitFor(driver, WebDriverUtils.configuredImplicityWait(), By.id("username"),
            this.getClass().toString());
    driver.findElement(By.id("username")).sendKeys(System.getProperty("cas.username"));
    driver.findElement(By.id("password")).sendKeys(System.getProperty("cas.password"));
    driver.findElement(By.name("submit")).click();
}
项目:SwiftLite    文件:WebDriverFactory.java   
@Override
public WebDriver create() {
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setEnableNativeEvents(true);
    capability.setCapability(FirefoxDriver.PROFILE, profile);
    WebDriver driver = null;
    try {
        driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        //SessionId sessionId = ((RemoteWebDriver) driver).getSessionId();
        //log.info("Running test on node: " + SeleniumGridHandler.getNodeIpBySessionId(sessionId));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return driver;
}
项目:SwiftLite    文件:WebDriverFactory.java   
@Override
public WebDriver create() {
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setEnableNativeEvents(true);
    capability.setCapability(FirefoxDriver.PROFILE, profile);
    WebDriver driver = null;
    try {
        driver = new RemoteWebDriver(new URL("http://10.48.11.144:4444/wd/hub"), capability);
        //SessionId sessionId = ((RemoteWebDriver) driver).getSessionId();
        //log.info("Running test on node: " + SeleniumGridHandler.getNodeIpBySessionId(sessionId));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    return driver;
}
项目:FuncaoWeb    文件:DriverFireFox.java   
private void setProxy(FirefoxProfile profile, String proxy, int porta) {

        profile.setPreference("network.proxy.http", proxy);
        profile.setPreference("network.proxy.http_port", porta);

        profile.setPreference("network.proxy.ssl", proxy);
        profile.setPreference("network.proxy.ssl_port", porta);

        profile.setPreference("network.proxy.ftp", proxy);
        profile.setPreference("network.proxy.ftp_port", porta);

        profile.setPreference("network.proxy.gopher", proxy);
        profile.setPreference("network.proxy.gopher_port", porta);

        profile.setPreference("network.proxy.socks", proxy);
        profile.setPreference("network.proxy.socks_port", porta);
        profile.setPreference("network.http.defensive-auth-prompting", false);
        profile.setPreference("security.ask_for_password", 0);

    }
项目:glue-selenese    文件:SeleneseMethodProvider.java   
private static DesiredCapabilities getFirefoxCapabilities(String language) {
        if (System.getProperty("webdriver.gecko.driver") == null && ScriptMethods.environment("webdriver.gecko.driver") != null) {
            System.setProperty("webdriver.gecko.driver", ScriptMethods.environment("webdriver.gecko.driver"));
        }
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        // use marionette?
//      capabilities.setCapability("marionette", true);
        FirefoxProfile profile = new FirefoxProfile();
        if (language != null) {
            profile.setPreference("intl.accept_languages", language);
        }
        profile.setPreference("startup.homepage_welcome_url.additional", "");
        // in firefox 43, they enabled signatures for plugins
        // this is also fixed in firefox driver version 2.48
        profile.setPreference("xpinstall.signatures.required", false);
        capabilities.setCapability(FirefoxDriver.PROFILE, profile);
        capabilities.setCapability("marionette", true);
        return capabilities;
    }
项目:automation-test-engine    文件:FirefoxFeatureProfile.java   
/**
 * Instantiates a new profile creator.
 *
 * @param profileName
 *            the profile name
 */

public FirefoxFeatureProfile(   String profileName) {
    super(); 
    if (StringUtils.isEmpty(profileName)) {
        throw new IllegalArgumentException();
    }
    this.profileName = profileName;

    ProfilesIni profileIni = new ProfilesIni();
    FirefoxProfile tmpProfile = profileIni.getProfile(profileName);
    if (null == tmpProfile) {
        throw new IllegalArgumentException(
                "Could not find the browser profile.");
    } else {
        this.profile = tmpProfile;
    }

}
项目:selenium-java-robot    文件:LocalRobotizedBrowserFactory.java   
public static LocalRobotizedBrowserFactory createRobotizedWebDriverFactory(String browser) {
    if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) {
        FirefoxProfile firefoxProfile = null;
        String firefoxProfileProperty = System.getProperty("webdriver.firefox.profile");
        if (firefoxProfileProperty == null) {
            ProfilesIni allProfiles = new ProfilesIni();
            // Use the default profile to make extensions available,
            // and especially to ease debugging with Firebug
            firefoxProfile = allProfiles.getProfile("default");
        }
        return new LocalFirefox(firefoxProfile);
    } else if (BrowserType.SAFARI.equalsIgnoreCase(browser)) {
        return new LocalSafari();
    } else if (BrowserType.CHROME.equalsIgnoreCase(browser)) {
        return new LocalBrowser<ChromeDriver>(ChromeDriver.class);
    } else if ("chrome-debug".equalsIgnoreCase(browser)) {
        return new LocalDebuggableChrome();
    } else if (BrowserType.IE.equalsIgnoreCase(browser)) {
        return new LocalBrowser<InternetExplorerDriver>(InternetExplorerDriver.class);
    } else {
        throw new RuntimeException("Unknown browser value: " + browser);
    }

}
项目:zucchini    文件:SeleniumDriver.java   
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);
}
项目:Cognizant-Intelligent-Test-Scripter    文件:WebDriverFactory.java   
private static DesiredCapabilities getFFUAECaps(DesiredCapabilities caps, Emulator emulator) {
    FirefoxProfile profile = new FirefoxProfile();
    if (!emulator.getUserAgent().trim().isEmpty()) {
        profile.setPreference("general.useragent.override", emulator.getUserAgent());
    }
    caps.setCapability(FirefoxDriver.PROFILE, profile);
    return caps;
}
项目:willtest    文件:JavascriptError.java   
@Override
public void adjustFirefoxProfile(FirefoxProfile firefoxProfile) {
    try {
        JavaScriptError.addExtension(firefoxProfile);
        initialized = true;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:willtest    文件:LocalFirefoxProvider.java   
@Override
protected FirefoxDriver constructWebDriver(DesiredCapabilities desiredCapabilities) {
    FirefoxBinary firefoxBinary = getFirefoxConfiguration().getFirefoxBinary();
    FirefoxProfile profile = getFirefoxConfiguration().getFirefoxProfile();
    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setBinary(firefoxBinary);
    firefoxOptions.setProfile(profile);
    return new FirefoxDriver(firefoxOptions);
}
项目:willtest    文件:DefaultFirefoxConfigurationParticipant.java   
@Override
public void adjustFirefoxProfile(FirefoxProfile firefoxProfile) {
    firefoxProfile.setPreference("geo.prompt.testing", true);
    firefoxProfile.setPreference("geo.prompt.testing.allow", true);
    //disable multi-process tabs -> avoids crashing of tabs with the message "Gah. Your tab just crashed!!!".
    firefoxProfile.setPreference("browser.tabs.remote.autostart.2", false);
    firefoxProfile.setPreference("browser.tabs.remote.autostart", false);
}
项目:redirector    文件:GenericTestUtils.java   
public static FirefoxProfile createProfileNeverAskSaving(String pathToDownloadDir) {
    FirefoxProfile result = new FirefoxProfile();
    result.setPreference("browser.download.folderList", 2);
    result.setPreference("browser.download.manager.showWhenStarting", false);
    result.setPreference("browser.download.dir", pathToDownloadDir);
    result.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xml, application/json, application/vnd.ms-excel");

    return result;
}
项目:cucumber-jvm-java-maven-parallel-picocontainer-selenium-webdriver-pagefactory-skeleton    文件:FirefoxBrowser.java   
public static FirefoxBrowser buildFirefoxBrowser() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);

    FirefoxBrowser browser = new FirefoxBrowser(profile);
    browser.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    return browser;
}
项目:GeoCrawler    文件:HttpWebClient.java   
@Override
protected WebDriver initialValue()
{
  FirefoxProfile profile = new FirefoxProfile();
  profile.setPreference("permissions.default.stylesheet", 2);
  profile.setPreference("permissions.default.image", 2);
  profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
  WebDriver driver = new FirefoxDriver(profile);
  return driver;
}
项目:otinane    文件:ObjectFormBookDoneTestNA.java   
@Test
public void BookDoneAnswered() {

    System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("geo.prompt.testing", true);
    profile.setPreference("geo.prompt.testing.allow", true);
    WebDriver driver = new FirefoxDriver(profile);


    driver.navigate().to("http://localhost:8080/login");
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.findElement(By.name("username")).clear();
    driver.findElement(By.name("username")).sendKeys("TestAcc3");
    driver.findElement(By.name("password")).clear();
    driver.findElement(By.name("password")).sendKeys("12345678");
    driver.findElement(By.xpath("//button[@type='submit']")).click();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.navigate().to("http://localhost:8080/");
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.findElement(By.xpath("//div[@id='map-canvas']/div/div/div/div[3]")).click();


    //  driver.findElement(By.xpath("//div[@id='map-canvas']/div/div/div/div[3][title='Books.png']")).click();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);


}
项目:awplab-core    文件:SeleniumProvider.java   
@Override
public FirefoxProfile getFirefoxProfile() {
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    processOptionValues(firefoxProfilePreferencePairs, (name, value) -> {
        if (value instanceof Integer) firefoxProfile.setPreference(name, (Integer)value);
        if (value instanceof Boolean) firefoxProfile.setPreference(name, (Boolean)value);
        if (value instanceof String) firefoxProfile.setPreference(name, (String)value);
    });
    firefoxProfile.setAcceptUntrustedCertificates(firefoxProfileTrustAllCerts);
    return firefoxProfile;
}
项目:PatatiumWebUi    文件:TestBaseCase.java   
/**
 * 用枚举类型列出浏览器列表,用于设置浏览器类型的函数参数
 * @author zheng
 *
 */
private WebDriver setDriver(String browsername)
{
    switch (browsername)
    {

        case "FirefoxDriver" :
            System.setProperty("webdriver.firefox.bin", "C:/Program Files (x86)/Mozilla Firefox/firefox.exe");
            FirefoxProfile firefoxProfile=new FirefoxProfile();
            //设置默认下载路径
            firefoxProfile.setPreference("browser.download.folderList", 2);
            firefoxProfile.setPreference("browser.download.dir", "D:\\自动化测试下载文件");
            //加载firebug插件
            firefoxProfile.setPreference("extensions.firebug.currentVersion", "2.0.13");
            firefoxProfile.setPreference("extensions.firebug.allPagesActivation", "none");
            //加载firepath插件
            firefoxProfile.setPreference("extensions.firepath.currentVersion", "0.9.7.1.1");
            firefoxProfile.setPreference("extensions.firepath.allPagesActivation", "on");
            this.driver=new FirefoxDriver(firefoxProfile);
            break;
        case "ChormeDriver":
            System.setProperty("webdriver.chrome.driver", "resource\\chromedriver.exe");
            this.driver=new ChromeDriver();
            break;
        case "InternetExplorerDriver":
            System.setProperty("webdriver.ie.driver", "resource\\IEDriverServer_Win32_2.48.0\\IEDriverServer.exe");
            DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
            dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
            dc.setCapability("ignoreProtectedModeSettings", true);
            this.driver=new InternetExplorerDriver(dc);
            break;
        case "HtmlUnitDriver":
            this.driver=new HtmlUnitDriver();
            break;
        default:
            this.driver=new FirefoxDriver();
            break;
    }
    return driver;
}
项目:SeleniumCucumber    文件:FirefoxBrowser.java   
public Capabilities getFirefoxCapabilities() {
    DesiredCapabilities firefox = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
    firefox.setCapability(FirefoxDriver.PROFILE, profile);
    firefox.setCapability("marionette", true);
    return firefox;
}
项目:domui    文件:WebDriverFactory.java   
private static DesiredCapabilities getFirefoxCapabilities(Locale lang) {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", lang.getLanguage().toLowerCase());
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability(FirefoxDriver.PROFILE, profile);

    //-- Not supported anymore, see https://github.com/mozilla/geckodriver/issues/617
    //capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
    return capabilities;
}
项目:blog-2016-01-selenium-on-travis    文件:UseNewFirefoxOnTravisTest.java   
@BeforeClass
public static void setUp() throws IOException {
    String travisCiFlag = System.getenv().get("TRAVIS");
    FirefoxBinary firefoxBinary = "true".equals(travisCiFlag)
            ? getFirefoxBinaryForTravisCi()
            : new FirefoxBinary();

    driver = new FirefoxDriver(firefoxBinary, new FirefoxProfile());
}
项目:webdrivermanager-examples    文件:WebRtcRemoteFirefoxTest.java   
@Before
public void setup() throws MalformedURLException {
    DesiredCapabilities capabilities = firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("media.navigator.permission.disabled", true);
    profile.setPreference("media.navigator.streams.fake", true);
    capabilities.setCapability(PROFILE, profile);

    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),
            capabilities);
}
项目:webdrivermanager-examples    文件:RemoteWebRtcFirefoxTest.java   
@Before
public void setupTest() throws MalformedURLException {
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("media.navigator.permission.disabled", true);
    profile.setPreference("media.navigator.streams.fake", true);
    capability.setCapability(FirefoxDriver.PROFILE, profile);
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),
            capability);
}
项目:zap-maven-plugin    文件:WebDriverFactory.java   
public static FirefoxDriver makeFirefoxDriver(String host, int port) {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.type", FIREFOX_MANUAL_PROXY_CONFIGURATION_OPTION);
    profile.setPreference("network.proxy.share_proxy_settings", true);
    profile.setPreference("network.proxy.no_proxies_on", "");
    profile.setPreference("network.proxy.http", host);
    profile.setPreference("network.proxy.http_port", port);

    return new FirefoxDriver(profile);
}
项目:aet    文件:FirefoxWebDriverFactory.java   
@Override
public WebCommunicationWrapper createWebDriver() throws WorkerException {
  try {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    FirefoxProfile fp = getFirefoxProfile();
    capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

    return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), null,
        requestExecutorFactory
            .createInstance());
  } catch (Exception e) {
    throw new WorkerException(e.getMessage(), e);
  }
}
项目:aet    文件:FirefoxWebDriverFactory.java   
private AetFirefoxDriver getFirefoxDriver(FirefoxProfile fp, DesiredCapabilities capabilities)
    throws IOException {
  AetFirefoxDriver driver;
  if (StringUtils.isBlank(path)) {
    driver = new AetFirefoxDriver(capabilities);
  } else {
    FirefoxBinary binary = new FirefoxBinary(new File(path));
    driver = new AetFirefoxDriver(binary, fp, capabilities);
  }
  driver.manage().timeouts().pageLoadTimeout(5L, TimeUnit.MINUTES);
  return driver;
}
项目:adf-selenium    文件:FirefoxDriverResource.java   
protected FirefoxProfile createProfile(String language) {
    FirefoxProfile profile = new FirefoxProfile();
    // native events cause "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsINativeMouse.click]"
    // on Windows with multiple calls to AdfSelectOneChoice.clickItemByIndex (and others)
    profile.setEnableNativeEvents(false);
    profile.setPreference("app.update.enabled", false); // don't bother updating Firefox (takes too much time)
    profile.setPreference("browser.usedOnWindows10", true); // don't show first-time windows 10 welcome page
    profile.setPreference("intl.accept_languages", language);
    return profile;
}
项目:adf-selenium    文件:BotStyleTest.java   
@Before
public void setup() {
    final FirefoxProfile profile = new FirefoxProfile();
    profile.setEnableNativeEvents(true);
    profile.setPreference("app.update.enabled", false);
    driver = new FirefoxDriver(profile);

    DialogManager.init(driver, TIMEOUT_MSECS);
    dialogManager = DialogManager.getInstance();
}
项目:jsflight    文件:SeleniumDriver.java   
private FirefoxDriver createFirefoxDriver(String display, String binaryPath,
        DesiredCapabilities desiredCapabilities)
{
    FirefoxProfile profile = createDefaultFirefoxProfile();
    FirefoxBinary binary = !StringUtils.isBlank(binaryPath) ? new FirefoxBinary(new File(binaryPath))
            : new FirefoxBinary();

    LOG.info("Binding to {} display", display);
    availableDisplays.compute(display, (d, value) -> value == null ? 1 : value + 1);
    binary.setEnvironmentProperty(DISPLAY, display);
    LOG.info("Firefox path is: {}", binaryPath);

    return openFirefoxDriver(desiredCapabilities, profile, binary);
}
项目:jsflight    文件:SeleniumDriver.java   
private FirefoxDriver openFirefoxDriver(DesiredCapabilities desiredCapabilities, FirefoxProfile profile,
        FirefoxBinary binary)
{
    try
    {
        return new FirefoxDriver(binary, profile, desiredCapabilities);
    }
    catch (WebDriverException ex)
    {
        LOG.warn(ex.getMessage());
        awakenAllDrivers();
        return openFirefoxDriver(desiredCapabilities, profile, binary);
    }
}
项目:kc-rice    文件:WebDriverUtils.java   
/**
 * <p>
 * remote.public.driver set to chrome or firefox (null assumes firefox).
 * </p><p>
 * if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)
 * if proxy.host is set, the web driver is setup to use a proxy
 * </p>
 *
 * @return WebDriver or null if unable to create
 */
public static WebDriver getWebDriver() {
    String driverParam = System.getProperty(HUB_DRIVER_PROPERTY);
    String hubParam = System.getProperty(HUB_PROPERTY);
    String proxyParam = System.getProperty(PROXY_HOST_PROPERTY);

    // setup proxy if specified as VM Arg
    DesiredCapabilities capabilities = new DesiredCapabilities();
    WebDriver webDriver = null;
    if (StringUtils.isNotEmpty(proxyParam)) {
        capabilities.setCapability(CapabilityType.PROXY, new Proxy().setHttpProxy(proxyParam));
    }

    if (hubParam == null) {
        if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
            FirefoxProfile profile = new FirefoxProfile();
            profile.setEnableNativeEvents(false);
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            return new FirefoxDriver(capabilities);
        } else if ("chrome".equalsIgnoreCase(driverParam)) {
            return new ChromeDriver(capabilities);
        } else if ("safari".equals(driverParam)) {
            System.out.println("SafariDriver probably won't work, if it does please contact Erik M.");
            return new SafariDriver(capabilities);
        }
    } else {
        try {
            if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.firefox());
            } else if ("chrome".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.chrome());
            }
        } catch (MalformedURLException mue) {
            System.out.println(getHubUrlString() + " " + mue.getMessage());
            mue.printStackTrace();
        }
    }
    return null;
}