I use Java Selenium to run multiple tests, with Chromedriver and Chrome.
I know how to set the capabilities and options.
https://developer.chrome.com/docs/chromedriver/capabilities
Now I have some test cases that need different options, in particular the network data from the perfLogging – but I do not need this for most of my test cases.
At the same time, I want to re-use my chromedriver and chrome instance, instead of discarding it and re-creating a new one every time (to speed up my testing and avoid the overhead).
Is there a way to modify the capabilities (using Java) of an existing chromedriver instance, basically just like what I would do as a user when changing the settings in my running browser?
Basically something like:
ChromeOptions initialOptions = new ChromeOptions();
WebDriver myDriver = new ChromeDriver(initialOptions);
ChromeOptions updatedOptions = new ChromeOptions();
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.PERFORMANCE, Level.ALL);
updatedOptions.setCapability("goog:loggingPrefs", logs);
// now how to apply the new options?