1

I set up Firefox's profile and launched the driver with that profile, after that, I want to know how to change some preferences on that profile multiple times, or how to change the profile after launching the driver? here is my code for setting up the profile:

profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.helperApps.alwaysAsk.force', False)
profile.set_preference('browser.download.dir', 'D:\\Workspace\\Res')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "application/x-7z-compressed")


driver = webdriver.Firefox(profile, executable_path=r"C:\geckodriver\geckodriver.exe")
ynsmtkl
  • 105
  • 3
  • 10

1 Answers1

2

As per the current implementation of Selenium once you configure the WebDriver instance with the required Options and Capabilities and initialize the Web Browser session to open a Browsing Context, you cannot change the capabilities runtime. Even if you are able to retrieve the runtime capabilities still you won't be able to change them back.

So, in-order to change the User Profile you have to initiate a new WebDriver session.


Reference

Here is @JimEvans clear and concise comment (as of Oct 24 '13 at 13:02) related to proxy settings capability:

When you set a proxy for any given driver, it is set only at the time WebDriver session is created; it cannot be changed at runtime. Even if you get the capabilities of the created session, you won't be able to change it. So the answer is, no, you must start a new session if you want to use different proxy settings.


Outro

You can find a relevant detailed discussion in How to set selenium webdriver from headless mode to normal mode within the same session?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352