当前位置: 首页>>代码示例>>Java>>正文


Java FirefoxProfile类代码示例

本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxProfile的典型用法代码示例。如果您正苦于以下问题:Java FirefoxProfile类的具体用法?Java FirefoxProfile怎么用?Java FirefoxProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FirefoxProfile类属于org.openqa.selenium.firefox包,在下文中一共展示了FirefoxProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: adjustFirefoxProfile

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:willhaben,项目名称:willtest,代码行数:17,代码来源:AdBlockerConfigurator.java

示例2: setDesiredCapabilities

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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!");
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:22,代码来源:SeleniumUtil.java

示例3: createWebDriver

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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;

}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:27,代码来源:SeleniumUtil.java

示例4: setDesiredCapabilities

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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!");
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:27,代码来源:SeleniumUtil.java

示例5: Firefox

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
/**
 * 本地初始化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);
        }
    }
}
 
开发者ID:Airpy,项目名称:KeywordDrivenAutoTest,代码行数:22,代码来源:Firefox.java

示例6: createWebDriver

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:25,代码来源:FirefoxWebDriverFactory.java

示例7: getFirefoxProfile

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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;
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:17,代码来源:FirefoxWebDriverFactory.java

示例8: createDefaultFirefoxProfile

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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;
}
 
开发者ID:d0k1,项目名称:jsflight,代码行数:25,代码来源:SeleniumDriver.java

示例9: login

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:JiraIssueCreation.java

示例10: create

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
@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;
}
 
开发者ID:MastekLtd,项目名称:SwiftLite,代码行数:17,代码来源:WebDriverFactory.java

示例11: setProxy

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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);

    }
 
开发者ID:confsoft,项目名称:FuncaoWeb,代码行数:21,代码来源:DriverFireFox.java

示例12: getFirefoxCapabilities

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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;
	}
 
开发者ID:nablex,项目名称:glue-selenese,代码行数:20,代码来源:SeleneseMethodProvider.java

示例13: FirefoxFeatureProfile

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
/**
 * 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;
	}

}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:25,代码来源:FirefoxFeatureProfile.java

示例14: createRobotizedWebDriverFactory

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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);
    }

}
 
开发者ID:attester,项目名称:selenium-java-robot,代码行数:25,代码来源:LocalRobotizedBrowserFactory.java

示例15: createFireFoxDriver

import org.openqa.selenium.firefox.FirefoxProfile; //导入依赖的package包/类
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);
}
 
开发者ID:entelgy-brasil,项目名称:zucchini,代码行数:12,代码来源:SeleniumDriver.java


注:本文中的org.openqa.selenium.firefox.FirefoxProfile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。