Change ChromeOptions in an existing webdriver

When you configure an instance of a ChromeDriver through ChromeOptions to initiate a new Chrome Browser the configuration gets baked into the chromedriver executable which will persist for the lifetime of the WebDriver and remain uneditable.

Even if you are able to extract the ChromeDriver and ChromeSession attributes e.g. Session ID, Cookies and other session attributes from the initiated Browsing Session still you won’t be able to change those attributes of the ChromeDriver.

A cleaner way would be to call driver.quit() within tearDown(){} method to close and destroy the ChromeDriver and Chrome Browser instances gracefully and then span a new set of ChromeDriver and Chrome Browser instance with the new set of configurations.


tl; dr

You can find a couple of relevant discussions in:

Leave a Comment