How to switch from one browser to another, then return to the initial browser and continue further test

Hello Katalon Team, i am currently doing a test scenarios for a proof of concept and however being blocked. Below is my scenario:

The typical scenario requires the tester (using always the same identity) to handle THREE browsers simultaneously:

  1. access an App in Browser1 , get redirected to an app for authentication, get a session, get access
  2. access an App in Browser2 , get redirected to an app for authentication, get a session, get access
  3. in Browser1 , observe that access to another app is transparent, no re-authentication is required
  4. access an app in Browser3 , get redirected to an application for authentication, get a session, get access
  5. in Browser2 , observe that access to another app is transparent, no re-authentication is required
  6. in Browser1 , observe that the session is gone, i.e., that the identity is redirected for re-authentication.

@kazurayam, could you please help how to overcome that issue? I checked on the forum but could not get a solution for the above typical scenario.

Thanks in advance.

I am sorry, I do not understand your description above. You described something, but have not made any question.

What is “that issue”?

Have you been successful for the step#1?
Have you been successful for the step#2?
Have you been successful for the step#3?
Have you been successful for the step#4?
Have you been successful for the step#5?
Have you been successful for the step#6?

I don’t see.

The issue is that, after opening browser 1 and browser 2, im not able to switch to browser 1 to perform a test. Then switch to browser 2 to perform another test. That switching is my issue :frowning:

Please show your test case script.

here is a screenshot:

Every detail is hidden in your custom keywords. I can not help you debugging your custom keywords.

  1. open browsers:

  2. repeat this keyword twice

  3. after opening the 2 browsers, i want to switch back to the first browser

  4. Perform some test in browser 1, then switch to browser 2, in the same flow…

Is it a it clear?

Essentially you are doing this:

WebUI.openBrowser(null)   // browser1
WebUI.openBrowser(null)   // browser2

Yes, you would see 2 browser windows opened.

But, you will loose the 1st session from Katalon to the browser1 as soon as the 2nd session started.

is there a solution, to switch back to the first session?

You should not use WebUI.openBrowser() at all. It maintains only 1 session from Katalon process to browser.

You should create multiple WebDriver instances (ChromeDrvier, FirefoxDriver) yourself. You want to create 2 instances and keep them alive. Use DriverFactoy.changeWebDriver() method to switch the target of WebUI.* keywords to the browser1, to the browser2, and back to the browser1, …

The following code works for me.

import org.openqa.selenium.WebDriver

import com.kazurayam.ks.webdriverfactory.WebDriverFactory
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

// open browser1, keep the session to the browser1 alive
//WebDriver browser1 = WebDriverFactory.newWebDriver(DriverFactory.getExecutedBrowser(), 'Katalon') // open browser with profile 'Katalon'
WebDriver browser1 = WebDriverFactory.newWebDriver(DriverFactory.getExecutedBrowser())  
assert browser1 != null

// open browser2, keep the session to the browser2 alive
WebDriver browser2 = WebDriverFactory.newWebDriver(DriverFactory.getExecutedBrowser())
assert browser2 != null

// in browser1, navigate to a URL

// in browser2, navigate to a URL

// switch to browser1 and do something
String title1 = WebUI.getWindowTitle()
WebUI.comment("title1: ${title1}")

// switch to browser2 and do something
String title2 = WebUI.getWindowTitle()
WebUI.comment("title2: ${title2}")



You can create ChromeDriver yourself using* API. This API is bundled in Katalon Studio and available for test cases. See

In the above sample, I use com.kazurayam.ks.webdriverfactory.WebDriverFactory. It is my custom Groovy class. Have a look at its README. This enables me creating WebDriver instance with custom Chrome Profile (e.g, Katalon). The jar (ver 0.3.0) of this class is available at You want to download the jar and locate it into the Drivers folder of your katalon project. To be honest, the doc of webdriverfactory project is not well written; I know the doc has some mistakes. I have already lost my interest in it.

1 Like

Hello @kazurayam, thank you. Have a nice weekend & stay safe.