twitch after coffee
twitch after coffee

Reputation: 713

How can I set up Selenium to use multiple Firefox profiles?

I am using selenium and want to use separate firefox profiles for 3 different scripts. Is this possible?

Upvotes: 1

Views: 1780

Answers (1)

RocketDonkey
RocketDonkey

Reputation: 37279

Not sure how you are executing your scripts, but when you instantiate your webdriver object, you can specify a FirefoxProfile as the firefox_profile argument. This is done by creating a FirefoxProfile object (example below) and providing the path to your target profile as the argument:

from selenium import webdriver
# ...
profile = webdriver.firefox.firefox_profile.FirefoxProfile('/path/to/your/profile')
driver = webdriver.Firefox(firefox_profile=profile)

To the best of my knowledge you can't modify the profile after the driver has been instantiated (I could be wrong about this though - worth experimenting if that is what you need to do :) ). That being the case, in each of your scripts you would create a profile that pointed to the profile you want to use, and then instantiate the driver with the firefox_profile argument pointed to the profile object created by FirefoxProfile.

Upvotes: 4

Related Questions