
You might not know that Selenium provides a feature which allows you to capture the network traffic during a test. This might be handy in some cases - for example if you want to check the HTTP response headers returned by the server for some reason or to verify that a specific HTTP request is triggered during a test. I use it for example to verify that a web analytics request is properly triggered on a particular web page.
To use this feature you must start your tests by providing a special option to the start method, i.e. selenium.start("captureNetworkTraffic=true");
Another useful Selenium feature I use is the ability to start the RC server by providing a specific Firefox profile for running the tests. Your normal Firefox settings are not used when running tests in *chrome mode. If you want to have a specific Firefox plugin active, or if for example you must use a proxy to access the tested pages, you have to use the -firefoxProfileTemplate setting when starting the Selenium server and provide the path to a custom Firefox profile folder that contains all the settings and plugins you want to use.
The problem is that those two features do not work together - when I use the captureNetworkTraffic=true option, I always get some generic Firefox profile and not the one I provide in the firefoxProfileTemplate parameter.
Here is my workaround for this problem. It turns out that inside the Selenium RC server jar there is a folder called customProfileDirCUSTFFCHROME, which contains the small generic firefox profile, used in this case and probably also in the case when you don't provide a custom Firefox profile.
If you want to capture the network traffic and still use a custom Firefox profile, here is how you can hack your selenium-server.jar to include a custom profile.
- Extract the customProfileDirCUSTFFCHROME folder from selenium-server.jar
- Close all Firefox processes. Start Firefox with the -profilemanager option.
- Choose 'Create Profile' from the dialog that appears, click 'Choose Folder' and select the folder extracted from the jar file.This way you will use the profile provided by selenium as a starting point. You can then make configuration changes, add plugins etc.
- When you exit firefox, pack all the changed files from the extracted profile folder back into the jar file. Now selenium will always use your custom profile
I tested this with Selenium 1.0.3. Works like a charm.