Opening Chrome browser in incognito mode and using WebUI

Hi.

I am attempting to (1) open Chrome browser in incognito mode, and then (2) use WebUI functions on that window. I am able to successfully implement (1) using the following code:

ChromeOptions options = new ChromeOptions();
options.addArguments("–incognito");
chromedriver_location = “C:\Program Files\Katalon_Studio_Windows_32-7.6.2\configuration\resources\drivers\chromedriver_win32\chromedriver.exe”
System.setProperty(“webdriver.chrome.driver”, chromedriver_location);
WebDriver driver = new ChromeDriver(options);
selenium = new WebDriverBackedSelenium(driver, GlobalVariable.UL_URL)
driver.quit()

This code automatically opens chrome in incognito mode in the bold line. I am able to afterward use selenium. functions to navigate in the window. However, I wish as well to use WebUI. functions to navigate and verify. But no matter where I place a simple WebUI.openBrowser("") in this code; before, in-between, or after the given lines, the system instead opens a SECOND chrome browser window in normal mode in which I am able to use WebUI.

But how do I open the chrome browser in incognito mode AND use WebUI in it?

For whats its worth, here is the code I traditionally use to open chrome browser in normal mode and in which I am able to use both selenium and WebUI functions.

WebUI.openBrowser(GlobalVariable.UL_URL)
def driver = DriverFactory.getWebDriver()
selenium = new WebDriverBackedSelenium(driver, GlobalVariable.UL_URL)
WebUI.navigateToUrl(GlobalVariable.SUA_URL)

It would be nice to convert it to open in incognito mode but I have so far failed.

Thanks.
Ilya

I don’t know this is the answer, but it seems relevant:

https://docs.katalon.com/javadoc/com/kms/katalon/core/webui/driver/DriverFactory.html#changeWebDriver(org.openqa.selenium.WebDriver)

Perhaps pass it the selenium driver instance?

These guys may know more:

@kazurayam @duyluong

My proposal is here:

Thank you. This works perfectly.