Step – 1: Create a Firefox profile that you want to use with selenium
How to create Firefox profile for your Selenium?
- Make sure all your firefox instance are closed
- Click Start>Run
- Type “firefox.exe -ProfileManager -no-remote”
- Select “Create Profile” (i.e. selenium)
- Click “Next”
- Enter new profile name. It is wise NOT to use the same name for your profile as you do for your profile folder (as described in step 7 below). So if your directory will be named "..\ffprofiles\seleniumAutomationProfile", then consider making your profile name "SeleniumUser" so you can tell them apart if you need to debug profile issues and find yourself looking at all kinds of logging, or configuration files/screens etc. Just makes it easier to immediately distinguish the two values.
- Select a directory folder to store your new profile. I have found that it is wise to create a "ffprofiles" directory in a common location where the rest of your automation folders can be found (a shared location regardless of the logged in user). Inside of that folder, create a "seleniumAutomationProfile" folder. Select this folder as the directory to store your new profile.
- Click “Finish”
- Select “Don’t ask at startup”
- Click “Start Firefox” and configure settings(below) based on suggestion below
- Set Profile back to “default” (enable you to use your previous settings on your browser)
Configure Settings (Optional)
- From “View\Toolbars” tab, uncheck “Bookmarks Toolbar”
- Right click from toolbar and click “Customize”
- Remove “Google search” by dragging it to the “Customize Toolbar” window
- From the “Customize Toolbar” window, click “Use Small Icons” check box then hit “Done”
- Click “Tools\Options” then set the following:
- “Main” tab
- set Home Page to “about:blank”
- uncheck “Show the Downloads..” option
- “Tabs” tab
- Select “a new window” for new pages
- Uncheck all warning options
- “Content” tab
- uncheck “Block pop-up” windows option
- “Privacy” tab
- uncheck all “History” options
- “Security” tab
- uncheck all “Security” options
- click “Settings” and uncheck all warning options
- “Advanced” tab
- Uncheck “autoscrolling” option from “General” tab
- uncheck “warn me …” and “Ssearch Engines”option from “Update” tab
- From “Tools\Add-ons” install the following:
- Selenium IDE: allows you to record, edit, and debug Selenium tests
- ScreenGrab: saves entire webpages as images.
- From the address bar type “about:config” and add the following by right-click anywhere on the page and selecting “new”
- extensions.update.notifyUser (type=boolean; value=false)
- extensions.newAddons (type=boolean; value=false)
Step-2 Handle Windows Authentication in firefox
Open firefox of above created profile
- Navigate to about:config (by typing in browser)
- Locate the following preference names and put as the value the comma separated values of the address roots.
- Your value should look something like this: localhost,server1,server2,serverX
- Now, open firefox and navigate to the site – it doesn’t prompt for uid and pwd
Step -3 Start selenium servers from command line using the firefox profile created in Step – 1
Java –jar selenium-server.jar –firefoxProfileTemplate "profilepath"
Note, that the -firefoxProfileTemplate parameter needs to be before the -htmlSuite parameter. And, if you are running the scripts remotely on a Windows 7 machine, your profile should be located in the "roaming" folder of your windows path, like such (NOTE: Unless of course you heeded my recommendations in Step 1, bullet number 7 and created the profile folder in a shared location, avoiding romaing profiles altogether):
START java -jar S:\selenium-server-standalone-2.31.0.jar -port 4446 -firefoxProfileTemplate "C:\Users\lalbright3\AppData\Roaming\Mozilla\Firefox\Profiles\gz3hlbly.default" -htmlSuite "*firefox" "http://www.google.com" "S:\scripts\OnlineDirectory\suite-datatests.html" "S:\scripts\OnlineDirectory\results\result.html"
Now, when you run server it will start selenium with an instance of the profile you’ve selected. VERY IMPORTANT NOTE: Using this method, the selenium server first copies the profile you created to its own unique instance. That is important to note because when the copied instance of that profile run in Selenium RC, the browser will not have the profile name you created associated with it because it is a copied instance ... instead, it will say something like "customProfileDir123456" on its title bar. A quick way of knowing that you do in fact have the right profile running, is by adding the "ShowProfile" plugin to your source profile and no other profiles. Then when the source profile is copied and starts running in its own instance, the ShowProfile plugin will show you the new unique copied instance name of the profile ... and because its showing the profile name at all on the title bar means the ShowProfile plugin that you installed ONLY to the source profile is in fact the copied version.
For example, if your source profile was named "seleniumUser" and you stored that profile in the "../ffprofiles/seleniumAutomationProfile" folder, and you installed the "ShowProfile" addon to this profile, then when the selenium server runs it will copy the source profile directory to a temporary location, naming it something like "customProfileDir456009" (see screenshot below) ... which is what will show from the ShowProfile addon when the browser launches. Your default firefox profile, not having the ShowProfile addon installed, will not.
In addition, you are not yet done. If you need certain things to be configured for your test executions, modifying the temporary firefox profile when it runs will NOT do the trick. That's because each time Selenium runs up, it copies the original source profile and gives its tmeporary folder an entirely new naming convention ... and therefore anything you do to the temporary profile will NOT BE SAVED for future runs. Instead, you need to make a test run using the original source profile to make your configurations changes. Then, and only then will your changes be copied over to the temporary profile for all future test runs.
The way this feature was originally documented led me to believe that a temporary profile was not being created ... and instead, it was using the source profile. That is NOT the case. So remember to modify your source profile first so that Selenium copies those configurations to any temporary profiles its creates during runtime. I struggled with this forever. I think because somewhere along the line, this behavior changes without explanation. Hope this helps someone else.
Some additional references: