Skip to content Skip to sidebar Skip to footer

How To Import And Export Firefox Profile For Selenium Webdriver In Python

How can I import and export a webdriver FireFox profile? What I wold like to do is something like: from selenium import webdriver #here I want to import the FF profile from a path

Solution 1:

You have to decide on a location to store the cached profile, then use functions in the os library to check if there is a file in that location, and load it. To cache the profile in the first place, you should be able to get the path to the profile from webdriver.firefox_profile.path, then copy the contents to your cache location.

All that said, I'd really recommend against this. By caching the profile created at test runtime, you are making your test mutate based upon previous behavior, which means it is no longer isolated and reliably repeatable. I'd recommend that you create a profile separately from the test, then use that as the base profile all the time. This makes your tests predictably repeatable. Selenium is even set up to work well with this pattern, as it doesn't actually use the profile you provide it, but instead duplicates it and uses the duplicate to launch the browser.

Post a Comment for "How To Import And Export Firefox Profile For Selenium Webdriver In Python"