Context
In my scraping project, we use a residential rotating proxy. To integrate this proxy into our Katalon project, we create a custom ChromeDriver
to pass into the DriverFactory
:
public static void SetUpDriver() {
// create if not exists the download directory
File downloadDir = new File(this.GetDownloadDirectory());
if (!downloadDir.exists()) {
downloadDir.mkdirs();
}
System.setProperty('webdriver.chrome.driver', ChromeDriverUtil.getChromeDriverPath())
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption('prefs', [
'download.prompt_for_download' : false,
'download.default_directory' : downloadDir.getPath(),
]);
Proxy proxy = ClientUtil.createSeleniumProxy(this.getProxy())
proxy.setHttpProxy(proxyAddress)
proxy.setSslProxy(proxyAddress)
options.setProxy(proxy)
options.addArguments("--disable-web-security");
options.addArguments("--ignore-urlfetcher-cert-requests");
options.setAcceptInsecureCerts(true)
driver = new ChromeDriver(options);
driver.manage().window().maximize();
System.out.println("Window size: " + driver.manage().window().getSize());
WebDriver eventDriver = new EventFiringDecorator<ChromeDriver>(new InitialNavigationEventListener()).decorate(driver);
DriverFactory.changeWebDriver(eventDriver);
}
This seems to work… as it is literally just updating our code to work with the new version fo Katalon Studio (v10)… However…
The problem
When running a sanity test case against the proxy integration, it errors, because the following exception got thrown on web driver setup:
Feb 08, 2025 11:56:49 PM com.kms.katalon.core.logging.KeywordLogger logError
SEVERE: ❌ java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.remote.SessionId.toString()" because the return value of "com.kms.katalon.core.webui.driver.DriverFactory.getRemoteSessionId(org.openqa.selenium.WebDriver)" is null
at com.kms.katalon.core.webui.driver.DriverFactory.logBrowserRunData(DriverFactory.java:435)
at com.kms.katalon.core.webui.driver.DriverFactory.changeWebDriver(DriverFactory.java:187)
at me.mikewarren.myCaseScraper.utils.WebDriverUtils.SetUpDriver(WebDriverUtils.groovy:69)
What are you trying to fix it?
I noticed that the new version of Katalon Studio (v10) has paywalled the ability to debug your scripts
To get around that, we attempt to “caveman-debug” :
assert driver.getClass().getMethod('getSessionId') != null
println driver.getClass().getMethod('getSessionId').invoke(driver);
The assertion passes, and we see a non-null session ID on the Console:
3e08b7d3c03b556bf9b714175ec172d2
NOTE: forced to do this roundabout bullshit to get the session ID, as an attempt to straight up just
println driver.getSessionId()
threw invocation error
Not sure how to fix this…