User:Dan Nessett/Technical/Minimizing Firefox on Startup
The account of this former contributor was not re-activated after the server upgrade of March 2022.
This page provides instructions how to minimize firefox on startup when using it as the target of a selenium test run.
Creating a SeleniumProfile for Firefox
In order to minimize the firefox browser window automatically when it is used as the target of a selenium test run, it is necessary to first create a special SeleniumProfile that is used for these tests. Detailed instructions how to do this are found at this URL. Summarizing, first run firefox's profile manager by executing (assuming a Linux OS):
$firefox -ProfileManager
This will start the profile manager. A window will appear showing you the profiles already defined and giving you the option of creating, deleting or renaming a profile.
If you have not used the profile manager before, the only profile shown will be the default. To set up firefox with a Selenium Profile, click on the Create Profile button. Click the next button at the bottom and in the text field type SeleniunProfile. Before clicking finish, look just below the text field and note where the profile is stored. Generally, this is in your personal mozilla directory using (for Ubuntu 8.04) a path such as: <your home directory>/.mozilla/firefox/gs4mzy7f.SeleniumProfile. Note that the name of the profile is prefixed by a random number. You will need this directory path information in a later step. If you forget to copy this down, you can always navigate to your personal mozilla directory and find the profile directory. When you click finish, an instance of firefox using the SeleniumProfile starts. Keep this browser window open for use in the next step. Once you have completed configuring the profile, you can return to using another profile (e.g., the default profile) by once again executing the profile manager as shown above, selecting the profile you wish to use and clicking on the Start Firefox button. The selected profile will remain in effect until you select another in the same way.
The Firefox Minimize on Start and Close addon
Installing the add-on
Once you have created a SeleniumProfile for selenium test runs, you need to install the Minimize on Start and Close addon to firefox. This is pretty easy. Startup firefox (make sure you are running under the SeleniumProfile) and click on tools at the top of the browser window and then select Add-ons. In the search field type: Minimize on Start and Close. Then click on the search icon or on the link Browse all addons. This will result in one or more add-ons that you may install on firefox. Choose the one named Minimize on Start and Close and click on the button Add to Firefox.
The addon should be installed. The addon manager will then provide you with the option of restarting firefox. Do this. When the browser comes up again. the add-on will be available.
Configuring the add-on
After installing the Minimize on Start and Close add-on, you must configure it to minimize on start. Once again, click on the tools menu item, select Add-ons, and then select extensions. You will see the Minimize on Start and Close add-on in the list of installed extensions. Click on the entry and buttons appear that allow you to Disable, Uninstall, and set the add-ons Preferences. Click on Preferences. A window will pop up.
Unselect the Minimize on close check box and select Minimize on start. You then should select an appropriate delay for minimization of the browser window after firefox starts. The default is 100 ms. This may not be long enough. If so, then the browser will not minimize on start. If this occurs, change the delay field to 1000 ms (1 second). This should be sufficient delay. You can play with this parameter so the browser window shows only briefly after firefox starts up.
Once you have changed the preferences, click the close button.
How to use the Minimize on Start and Close addon with selenium
You now have a SeleniumProfile that you can use with your selenium tests. Some other configuration of the profile is possible, but these instructions concentrate on using it to minimize the firefox browser window when each test run starts. You can read about other possible profile configuration changes here.
Using the firefox SeleniumProfile for selenium testing is trivial. When starting up the selenium server include the -firefoxProfileTemplate option, specifying the path to the SeleniumProfile you just created. For example, if the profile is located at: /path/to/the/Selenium/Profile, then the command to start the selenium server (on a Linux machine) would be :
java -jar /path/to/the/selenium/server/jar/file -firefoxProfileTemplate /path/to/the/Selenium/Profile
More specifically, on a Ubuntu 8.04 system where the SeleniumProfile is located in /home/dnessett/.mozilla/firefox/gs4mzy7f.SeleniumProfile, the command would be:
java -jar /usr/local/bin/selenium-server.jar -firefoxProfileTemplate /home/dnessett/.mozilla/firefox/gs4mzy7f.SeleniumProfile
Troubleshooting
- When using the SeleniumProfile with the -firefoxProfileTemplate selenium server option on an Ubuntu 8.04 system, each time the browser starts an addon information window pops up, informing the user that some extensions have been added. It isn't clear why this happens. After initial configuration, this addon window was not minimized, which effectively canceled the benefits of browser window minimization. However, after rebooting the OS, the addon information window still popped up, but it then minimized along with the browser window. When the test run completes, both the browser and addon information window close.