在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:saadtazi/firefox-profile-js开源软件地址:https://github.com/saadtazi/firefox-profile-js开源编程语言:JavaScript 99.7%开源软件介绍:firefox-profile-jsCreate or update Firefox Profile programmatically. Notes for Selenium-webdriver package usersIf you are using This package is also useful if you use another webdriver library like IntroductionThis package allows you to:
More info on user preferences here. It also contains a command line interface that allows to copy or create profiles. Installation
or
UsageMake sure you have selenium server running... or use 'selenium-webdriver/remote' class. Steps
I wanna see it!/******************************************************************
* with old version selenium webdriverJs
* WARNING: does not work with recent version of selenium-webdriver node bindings, which expect an instance of selenium-webdriver Firefox Profile page (`require('selenium-webdriver/firefox').Profile` or similar)
* @see: https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/profile_exports_Profile.html
* installs firebug
* and make http://saadtazi.com the url that is opened on new tabs
/******************************************************************/
var webdriver = require("selenium-webdriver");
// create profile
var FirefoxProfile = require("firefox-profile");
var myProfile = new FirefoxProfile();
// you can add an extension by specifying the path to the xpi file
// or to the unzipped extension directory
myProfile.addExtension("test/extensions/firebug-1.12.4-fx.xpi", function () {
var capabilities = webdriver.Capabilities.firefox();
// you can set firefox preferences BEFORE calling encoded()
myProfile.setPreference("browser.newtab.url", "http://saadtazi.com");
// attach your newly created profile
myProfile.encoded(function (err, encodedProfile) {
capabilities.set("firefox_profile", encodedProfile);
// start the browser
var wd = new webdriver.Builder().withCapabilities(capabilities).build();
// woot!
wd.get("http://en.wikipedia.org");
});
});
/**************************************************
/* with admc/wd
/* installs firebug, and make it active by default
/**************************************************/
var FirefoxProfile = require("firefox-profile"),
wd = require("wd");
// set some userPrefs if needed
// Note: make sure you call encoded() after setting some userPrefs
var fp = new FirefoxProfile();
// activate and open firebug by default for all sites
fp.setPreference("extensions.firebug.allPagesActivation", "on");
// activate the console panel
fp.setPreference("extensions.firebug.console.enableSites", true);
// show the console panel
fp.setPreference("extensions.firebug.defaultPanelName", "console");
// done with prefs?
fp.updatePreferences();
// you can install multiple extensions at the same time
fp.addExtensions(["./test/extensions/firebug-1.12.4-fx.xpi"], function () {
fp.encoded(function (err, zippedProfile) {
if (err) {
console.error("oops, an error occured:", err);
return;
}
browser = wd.promiseChainRemote();
// firefox 46-
//browser.init({
// browserName:'firefox',
// // set firefox_profile capabilities HERE!!!!
// firefox_profile: zippedProfile
//}).
// firefox 47+
browser.init({
browserName: "firefox",
marionette: true,
"moz:firefoxOptions": {
profile: zippedProfile,
},
});
// woOot!!
get("http://en.wikipedia.org");
});
}); You can also copy an existing profile... Check the doc Command Line InterfaceIt allows to copy (from profile name or profile directory) or create firefox profiles with installed extensions. Note that it does not allow to load user preferences... yet. Run
API DocumentationThe API documentation can be found in doc/. It can be regenerated using Tests
Coverage
Generates doc/coverage.html TODO
DisclaimerThis class is actually a port of the python class. Found a bug?Open a github issue. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论