Did you know that you can actually use Firefox Profile in your Selenium automation? It's even quite simple as you will figure out in this article.

To The Point

Creating a new Firefox Profile

Some command lines for firefox are described at this link, but not all of them are available at linux. I checked available commands with:

firefox --help

To create your profile:

firefox -P newprofile

It will popup with a ProfileManager that is not available at normal Firefox run. You can create in this window new profile.

I did so and It displayed a window with path to profile (which btw you can change) - it looks similar to this:

~/.mozilla/firefox/YOURUNIQUENAME.NAMEYOUENTERED

You cannot copy this path while creating profile, but when you go to path with profiles:

~/.mozilla/firefox/

You should see it.

We can do some changes on our profile with starting the same command

firefox -P newprofile

then clicking on "Start Firefox" while selecting profile that we want.

Starting Selenium with firefox profile:

    profile_path = '/home/anselmos/.mozilla/firefox/your_profile_path_directory_enter_here'
    profile = webdriver.FirefoxProfile(profile_path)
    driver = webdriver.Firefox(profile)

From now you can use a working profiled Selenium Firefox.

Snippets

    profile_path = '/home/anselmos/.mozilla/firefox/your_profile_path_directory_enter_here'
    profile = webdriver.FirefoxProfile(profile_path)
    driver = webdriver.Firefox(profile)

Acknowledgements

Auto-promotion

Related links

Thanks!

That's it :) Comment, share or don't :)

If you have any suggestions what I should blog about in the next articles - please give me a hint :)

See you in the next episode! Cheers!



Comments

comments powered by Disqus