Firefox profile with Selenium Webdriver
Firefox, like your home page, what toolbars you use, saved passwords and bookmarks are all stored in a special profile folder.
Get webdriver to come up with firebug:
Download the firebug xpi file from mozilla and start the profile as follows:
File ext= new File("firebug-1.8.1.xpi"); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(ext); firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen firefoxProfile.setPreference(“extensions.firebug.console.enableSites”, true); //enable console
//some more prefs:
firefoxProfile.setPreference( “app.update.enabled”, false);
firefoxProfile.setPreference( “browser.tabs.autoHide”, true);
//use this profile:
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(firefoxProfile);
Enabling features that are disabled by default in Firefox
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
WebDriver driver = new FirefoxDriver(profile);
Set language in profile
profile.setPreference( "intl.accept_languages", "no,en-us,en" );
Setting the AssumUntrustedCertificateIssuer of the FirefoxProfile object to false
profile.setAssumeUntrustedCertificateIssuer(false);
Creating a new profile using the Profile Manager•Close the application and make sure that it is not running in the background.•Start the Profile Manager
◦Windows
■Open the Windows “Start” menu, select “Run” (on Windows Vista, use “Start Search” or enable the Run box, as described here) then type and enter one of the following:
firefox.exe -P
or run the Profile Manager
"C:\Program Files\Mozilla Firefox\firefox.exe" -profilemanager
◦Linux
■Open the terminal and execute cd firefox program directory. If you don’t know where firefox is installed, you can always do
locate firefox
■Then execute:
./firefox -profilemanager
◦Mac OS X
■Assuming the program is installed in the “Applications” folder, launch Terminal (“Applications -> Utilities -> Terminal”)
■Enter the command starting with / after the prompt in Terminal:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager
To find which profile is really used when Firefox is running, do the following.
From Firefox click Help -> Troubleshooting Information
On the new tab with the title "Troubleshooting Information", click the button "Open Containing Folder"
Comments
Post a Comment