问题
Trynig to add a new, persistent, Firefox profile with Selenium. AFAIK, when executing FirefoxProfile()
, a new profile is generated using a temporary file. Ideally, this profile should be able to remain available to subsequent processes - even after the creator is closed.
Problem:
- Create a new Firefox profile from within Python code. This should return a FirefoxProfile object that is usable with the Firefox webdriver Selenium uses.
- The profile created should persist after the process ends - i.e. it should be a full-fledged profile, not just a temporary profile.
Some pointers:
The
profiles.ini
file seems to be key. I have read some code that uses the Java classProfilesIni
to modify profile information. If this class is available for Python code, it should probably take care of most of this.If the only way to do this is to manually modify the
profiles.ini
file, that's acceptable. A better, more standardized solution (one that uses a library or Selenium code) would be preferable, however.
Thanks very much!
回答1:
If this helps anyone, what needs to be done is run:
firefox[.exe] -CreateProfile <profile_name>
The .exe
in brackets is intended to provide for it being run under Windows.
Yes, this does not use the Selenium library in Python, but it does provide the desired result.
来源:https://stackoverflow.com/questions/16423309/how-to-create-a-new-persistent-firefox-profile-with-selenium-in-python