# A decorated WebDriver doesn't have a session ID ?!

**URL:** <https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [February 9, 2025, 5:04am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449 "2025-02-09T05:04:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 9, 2025, 5:04am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/1 "2025-02-09T05:04:35Z")

</div>

## 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`:

```auto
	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:

```auto
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” :

```auto
		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:

```auto
3e08b7d3c03b556bf9b714175ec172d2

```

NOTE: forced to do this roundabout bullshit to get the session ID, as an attempt to straight up just

```auto
println driver.getSessionId()

```

threw invocation error

Not sure how to fix this…

@kazurayam  
@Elly_Tran

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 9, 2025, 5:48am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/2 "2025-02-09T05:48:42Z")

</div>

It’s too difficult for me to look into your issue.

---

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 9, 2025, 5:56am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/3 "2025-02-09T05:56:35Z")

</div>

I’m sorry that you are facing difficulty looking into this…

What can I provide that would make this issue easier to look into?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [February 9, 2025, 6:16am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/4 "2025-02-09T06:16:05Z")

</div>

I can not reproduce your system on my side, so it is too difficult for me to look into your issue.

---

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 9, 2025, 6:26am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/5 "2025-02-09T06:26:12Z")

</div>

Oh, I am running Katalon Studio v10.0.1, free edition, on Windows 11 machine.

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [February 9, 2025, 4:20pm UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/6 "2025-02-09T16:20:59Z")

</div>

> [@mwarren04011990](#):
>
> `proxyAddress`

I don’t need a proxy, so I’m not familiar with the coding, however, where is the “proxyAddress” picked up from or is it static somewhere else?

```auto
        // Configure proxy settings
        String proxyAddress = "your_proxy_address:port";

```

And, AI says you may have an issue with **getting** the sessionId, so perhaps go through the release notes for KS 10 and see if you can find any updates on changes to get it.

Edit: And KS paywalled “Debug” way back in version 6 or 7. “Debug” was there in version 5.6, but it was paywalled when we upgraded to version 7 or 8 a few years ago.

---

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 9, 2025, 6:01pm UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/7 "2025-02-09T18:01:49Z")

</div>

We are using residential rotating proxy from a third party. This `proxyAddress` is picked up from static.

It is working, but for some reason we face issue on `DriverFactory.changeWebDriver(eventDriver);`

I will check out those release notes; // Katalon’s `DriverFactory.changeWebDriver()` is the one that is checking the driver’s session ID

---

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 9, 2025, 10:02pm UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/8 "2025-02-09T22:02:04Z")

</div>

A couple of updates here:

First, I found out that `!eventDriver instanceof RemoteWebDriver` (and the session ID only exist for `RemoteWebDriver`s)

As a matter of fact…

Second, I found out that when trying to declare `eventDriver` as `ChromeDriver`, that I face this issue:

```auto
SEVERE: ❌ org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Decorated {ChromeDriver: chrome on windows (d4accde383a42b77998f79731567a3a5)}' with class 'net.bytebuddy.renamed.java.lang.Object$ByteBuddy$MSuMTJy5' to class 'org.openqa.selenium.chrome.ChromeDriver'
	at me.mikewarren.myCaseScraper.utils.WebDriverUtils.SetUpDriver(WebDriverUtils.groovy:63)

```

## Ok, so get rid of the decorated shit and be done with this!

Problem is that, we **need** , in this project, to take some custom action to authenticate the proxy service!

In pure Selenium WebDriver, we don’t need to (we could just authenticate programmatically via that `proxyAddress` String), but in Katalon Studio, we would need to make an auth alert spawn from the proxy service, and handle it with an AutoIT script that inputs the proxy credentials…

This was working in Katalon Studio v9, but in v10, with the upgrade to Selenium WebDriver v4 it is not anymore after updating my code from:

```auto
		EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver);
		eventDriver.register(new InitialNavigationEventListener());

```

to

```auto
		WebDriver eventDriver = new EventFiringDecorator<ChromeDriver>(new InitialNavigationEventListener()).decorate(driver);

```

(and of course updating that `InitialNavigationEventListener` class)

Speaking of which…

**`eventDriver` happens to be an instance of `org.openqa.selenium.support.decorators.Decorated`** , and the **source code in Katalon Studio’s `DriverFactory.getRemoteSessionId()`** doesn’t handle that:

```auto
    private static SessionId getRemoteSessionId(WebDriver webDriver) {
        try {
            if (webDriver instanceof RemoteWebDriver) {
                return ((RemoteWebDriver) webDriver).getSessionId();
            }
        } catch (Exception e) {
            logger.logInfo(ExceptionUtils.getStackTrace(e));
        }
        return null;
    }

```

I recommend changing it to the following:

```auto
    private static SessionId getRemoteSessionId(WebDriver webDriver) {
        try {
            if (webDriver instanceof Decorated) { 
				return ((RemoteWebDriver)((Decorated) webDriver).getOriginal()).getSessionId();
            }

            if (webDriver instanceof RemoteWebDriver) {
                return ((RemoteWebDriver) webDriver).getSessionId();
            }
        } catch (Exception e) {
            logger.logInfo(ExceptionUtils.getStackTrace(e));
        }
        return null;
    }

```

@Elly_Tran @albert.vu

## UPDATE to the update…

Seems we would have to change a lot of places in the Katalon code base that we are doing `((RemoteWebDriver) webDriver)` to instead do a check on what `webDriver` actually is (is it `Decorated`)?

This new version of Selenium sure seems to be making things…difficult…

May be worth creating some util class/method to get the actual underlying web driver (similar to what I just did in this post) for the purposes of logging things like the browser name, version, session ID, etc…

…and for any puropse that does NOT boil down to logging something… we can simply use the `webDriver` object as-is.

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [February 11, 2025, 7:02am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/9 "2025-02-11T07:02:06Z")

</div>

Hi Michael @mwarren04011990, 👋

Thank you very much for sharing your issue with us. As our Product team has yet to see this issue before, we’ll report this to them so they can take a closer look at it. Hopefully, they’ll be able to provide you with workarounds or suggesstions.

* * *

Hi em @Elly_Tran, can you please create a KSR Jira ticket for our Product team and link Michael’s topic to it? Thanks em.

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [February 12, 2025, 2:14am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/11 "2025-02-12T02:14:14Z")

</div>

Hi @mwarren04011990,

Thank you for sharing your issue. I have created a ticket for my team to investigate this further. I will let you know soon if any updates.

---

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [February 12, 2025, 3:32pm UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/12 "2025-02-12T15:32:37Z")

</div>

Thank you for the update!

There is another issue, that I’ve been facing for longer…

… That I’ve been forced to code around…

That issue is with the Selenium proxy returned by `ClientUtil.createSeleniumProxy()`, somehow NOT having the HTTP and SSL proxies set.

This has forced us to basically set them ourselves, and have to manually authenticate the proxy before any navigation can happen.

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [February 13, 2025, 2:41am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/13 "2025-02-13T02:41:03Z")

</div>

Sure. I will deliver your issue to my team also. Thank you

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [April 15, 2025, 3:24am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/14 "2025-04-15T03:24:34Z")

</div>

Hi all,

Sorry for my late response. Our team is working on it and it’s planned for May/June patch release 10.2.1. Hope this can help you. Thank you

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [July 8, 2025, 8:39am UTC](https://forum.katalon.com/t/a-decorated-webdriver-doesnt-have-a-session-id/164449/15 "2025-07-08T08:39:54Z")

</div>

Hi all,

This issue has been fixed in [v10.2.3](https://docs.katalon.com/katalon-studio/release-notes/katalon-studio-release-notes-version-10.x#version-1023). Thank you for your patience.
