Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I'm using python 2.7.1 and selenium 2.20.0.
I have a seperate firefox profile called "selenium" which I want to use when running the webdriver.
I managed to do it by specifying the complete path to the profile as shown below, but that's not very portable code.

profile = FirefoxProfile("/Users/username/Library/Application Support/Firefox/Profiles/jtokyple.selenium")
self.driver = webdriver.Firefox(profile)

Is there any better way to specify the profile?

share|improve this question

3 Answers 3

If you want it to be portable, you need to have the firefox profile included in your build and copied to the working directory. You should be able to reference it from there easily. This will work even if you copy all of your tests to a different machine and execute them there.

share|improve this answer

Using WebDriver you can add any addons and change any configurations you want from the programming code. It's not required to create separate firefox profile

share|improve this answer
Great, so suppose I want to have a setting where files get downloaded automatically without a popup to a particular directory. I can set it manually in Firefox and it works for my user, but not when Selenium is driving it. How can I change this in code? –  Leonid Nov 20 '12 at 0:12

I've been using the following as a constant:

FF_PROFILE_PATH = os.path.join(os.environ['APPDATA'],
                               'Mozilla', 'Firefox', 'Profiles')

I believe it's consistent across OSes per Mozilla support documentation. To locate the correct profile, you can iterate through the list created by os.listdir to find the profile, as such:

    profiles = os.listdir(FF_PROFILE_PATH)
except WindowsError:
    print "Could not find profiles directory."
    loc = (folder for folder in profiles
           if folder.endswith(profile)).next()
except StopIteration:
    print "Firefox profile not found."
return os.path.join(FF_PROFILE_PATH, loc)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.