3

I tried the recommended method of loading a profile, but it's not working for me. It simply opens an empty profile.

from selenium.webdriver import Firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options


profile_path = r'E:/Python/seleniumProfile'
options=Options()
options.set_preference('profile', profile_path)
driver = Firefox(options=options)
driver.get("https://www.google.com")

No warning or error message is given, even if I type an invalid folder as the profile_path.

Old way works great, but gives the deprecation warning:

fp = webdriver.FirefoxProfile('E:/Python/seleniumProfile')
driver = webdriver.Firefox(fp)
driver.get("https://www.google.com")

DeprecationWarning: firefox_profile has been deprecated, please use an Options object

I guess I can live with the warnings, but any help would be appreciated.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Leo
  • 43
  • 5

1 Answers1

1

This error message...

firefox_profile has been deprecated, please pass in an Options object

...implies that usage of FirefoxProfile() have been Deprecated and with and to use a custom profile you have to use an instance of Options . This DeprecationWarning was inline with the following CHANGELOGS:


Solution

To use an existing firefox profile you can use the following solution:

from selenium.webdriver import Firefox
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options

profile_path = r'C:\Users\Admin\AppData\Roaming\Mozilla\Firefox\Profiles\s8543x41.default-release'
options=Options()
options.set_preference('profile', profile_path)
service = Service('C:\\BrowserDrivers\\geckodriver.exe')
driver = Firefox(service=service, options=options)
driver.get("https://www.google.com")

tl; dr

Setting a custom profile

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Didn't work for me. I thought maybe there could be a typo in my code, but I can't find it. Thanks anyway. – Leo Mar 23 '22 at 10:52
  • 1
    `options.set_preference("profile", profile_path)` doesn't set profile for me. Only calling `options.add_argument("-profile")` and `options.add_argument(profile_path)` does. – vintprox Mar 25 '23 at 14:10