Using default firefox profile with selenium webdriver in python

I know that similar questions have been asked before, but I tried many times, and this still does not work for me.

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

I have done this:

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

But I have 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 greatly appreciated.

+6
source share
2 answers

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

 C:/Users/admin/AppData/Roaming/Mozilla/Firefox/Profiles/c1r3g2wi.default 
+7
source

Alternatively, you can use a double backslash in the path:

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

Source: https://habr.com/ru/post/918433/


All Articles