Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the default firefox profile with selenium webdriver in python

I know similar questions have been asked before, but I've tried many times and it still doesn't work for me.

I only have a default profile in firefox (called c1r3g2wi.default) and no other profiles. I want my firefox browser to start with this profile when I launch it using the selenium webdriver. How do I do this in Python?

I did this:

fp = webdriver.FirefoxProfile('C:\Users\admin\AppData\Roaming\Mozilla\Firefox\Profiles\c1r3g2wi.default')
browser = webdriver.Firefox(fp)

But I got an error:

WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 
'C:\\Users\x07dmin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\c1r3g2wi.default/*.*'

Help, or pointers in the right direction, would be very much appreciated.

like image 634
K L Avatar asked Jun 19 '12 06:06

K L


People also ask

How do I run Firefox in Selenium Python?

To make Firefox work with Python selenium, you need to install the geckodriver. The geckodriver driver will start the real firefox browser and supports Javascript. Take a look at the selenium firefox code. First import the webdriver, then make it start firefox.

How do I change my default browser in Selenium?

We can open Chrome default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter. We need to use the ChromeOptions class to open the default Chrome profile. We need to use the add_argument method to specify the path of the Chrome profile.

Which is default browser of Selenium Webdriver?

Selenium comes with default Mozilla Firefox driver which is bundled in Selenium WebDriver jar file. That's why for calling Firefox driver, no setup is required. If we want to use other browsers, we need to set up its system property.


1 Answers

Ok, I just solved this by simply changing all the slashes in my file path from "\" to "/". Never knew this would make a difference.

C:/Users/admin/AppData/Roaming/Mozilla/Firefox/Profiles/c1r3g2wi.default
like image 143
K L Avatar answered Nov 03 '22 01:11

K L