Setting WebDriver instance at runtime

According to this documentation:

One can do something like:

WebDriver driver = new ChromeDriver()

However, looking at the source, it appears that the changeWebDriver() currently has a private access modifier:

private static void changeWebDriver(WebDriver webDriver) {

Is there any chance that this could become public facing again? If not, could we get another method to set a custom driver at runtime? If not, please update the documentation.

Some context:

I’m trying to implement a way to modify request headers programmatically using BrowserMob. Basically, I can instantiate my own webdriver, and associate a custom BrowserMob proxy (with custom headers) with that driver through desired capabilities. The problem is that I can’t then inject that back into the DriverFactory as shown above.

Thanks in advance!

I can confirm that in KS 7.2.1 DriverFactory#changeWebDriver() method is declared public.

On the other hand, the source code shared at katalon-studio-testing-framework/ at master · katalon-studio/katalon-studio-testing-framework · GitHub declares the method as private. The disclosed source code is obviously obsolete.

1 Like

Cool, thank you so much for checking this @kazurayam. This means our existing functionality won’t break (at least in 7.2.1).