People seem to have some problems when it comes to testing file uploads with Selenium RC. I’m not the first to provide a solution but making this work with Selenium RC might take a few more steps.
With Selenium RC you get a fresh browser each time you start a test run. So you’ll need to add this to your default profile in a You can upload files with Firefox if you build a custom profile with relaxed Javascript securities. You wouldn’t want to run this relaxed security version against any code that you don’t trust obviously, so be careful.
Step 1. Create a new Firefox profile.
Step 2. Edit prefs.js to include:
user_pref("signed.applets.codebase_principal_support", true);
Step 3. Modify your AUT (this is why this is bad way to test file uploads via Selenium) to request enhanced permissions via:
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
// This gives Javascript the ability to open file:// URI's.
Step 4. Visit your AUT using the profile you’ve just created, you’ll hopefully be greeted with a warning asking you if Javascript should be allowed UniversalFileRead permissions. Clicking yes will add entries to your prefs.js file that look like the following:
user_pref("capability.principal.codebase.p0.granted", "UniversalFileRead");
user_pref("capability.principal.codebase.p0.id", "http://your_aut_domain.com");
user_pref("capability.principal.codebase.p0.subjectName", "");
You can then edit your SeleniumRC instance to launch FireFox using this specific profile.
You can, and probably should, go farther with this by granting per file permissions.
More info: