本文整理汇总了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);
}
}
示例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!");
}
示例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;
}
示例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!");
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}