本文整理汇总了Java中org.openqa.selenium.firefox.FirefoxProfile.setPreference方法的典型用法代码示例。如果您正苦于以下问题:Java FirefoxProfile.setPreference方法的具体用法?Java FirefoxProfile.setPreference怎么用?Java FirefoxProfile.setPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.firefox.FirefoxProfile
的用法示例。
在下文中一共展示了FirefoxProfile.setPreference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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!");
}
示例2: 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;
}
示例3: 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!");
}
示例4: 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;
}
示例5: 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);
}
示例6: newFireFoxBrowser
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
private EmbeddedBrowser newFireFoxBrowser(ImmutableSortedSet<String> filterAttributes,
long crawlWaitReload, long crawlWaitEvent) {
if (configuration.getProxyConfiguration() != null) {
FirefoxProfile profile = new FirefoxProfile();
String lang = configuration.getBrowserConfig().getLangOrNull();
if (!Strings.isNullOrEmpty(lang)) {
profile.setPreference("intl.accept_languages", lang);
}
profile.setPreference("network.proxy.http", configuration
.getProxyConfiguration().getHostname());
profile.setPreference("network.proxy.http_port", configuration
.getProxyConfiguration().getPort());
profile.setPreference("network.proxy.type", configuration
.getProxyConfiguration().getType().toInt());
/* use proxy for everything, including localhost */
profile.setPreference("network.proxy.no_proxies_on", "");
return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
filterAttributes, crawlWaitReload, crawlWaitEvent);
}
return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(),
filterAttributes, crawlWaitEvent, crawlWaitReload);
}
示例7: 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);
}
示例8: getFFUAECaps
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
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;
}
示例9: adjustFirefoxProfile
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
@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);
}
示例10: createProfileNeverAskSaving
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
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;
}
示例11: initialValue
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
@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;
}
示例12: BookDoneAnswered
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
@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);
}
示例13: setDriver
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
/**
* 用枚举类型列出浏览器列表,用于设置浏览器类型的函数参数
* @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;
}
示例14: getFirefoxCapabilities
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
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;
}
示例15: setup
import org.openqa.selenium.firefox.FirefoxProfile; //导入方法依赖的package包/类
@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);
}