Sign up ×
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

4 Answers 4

I think, I rushed and just added code. Tested Ok below code with Selenium 2.4, python 2.7 Linux OS: mint17 Debian base.

# for fresh FF profile
#profile = webdriver.FirefoxProfile() 
profile = webdriver.FirefoxProfile("./firefox_profiles/selenium")
profile = webdriver.FirefoxProfile(profile_path)
driver = webdriver.Firefox(firefox_profile=profile)

I feel, it's good idea to have absolute path. In fact, put it in conf file so you can use it for various deployment instances and OSes. Relative path have to start from location where you have selenium .py file. It should work in same way on Windows. NOT tested on windows.

share|improve this answer
Your answer doesn't actually solve the problem stated in the question. You skipped the part of how to specify a relative profile path, which is what was asked. Additionally your answer would be better if you would include some explanation with your code. –  Edu Sep 8 at 7:22

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

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

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

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.