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.
This error message...
firefox_profile has been deprecated, please pass in an Options object
...implies that usage of FirefoxProfile() have been Deprecated and with selenium4 and to use a custom profile you have to use an instance of Options . This DeprecationWarning was inline with the following CHANGELOGS:
Selenium 4 beta 1
Options and Service arguments in driver instantiation. (#9125,#9128)Selenium 4 beta 2
Selenium 4 Beta 3
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")
Setting a custom profile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With