Open Katalon execution in the already opened browser

Actually I am trying to do a PoC in which I have the chrome open and I want to katalon to execute the steps in the new tab of already opened window . Is it possible ?? I googled alot but no solution seems to be working .

Are you saying that you’re opening a browser window manually, then you want Katalon to execute in this browser instance? If so, I don’t believe that is possible, because the instance will not have a chromedriver associated with it.

You can always have Katalon open a browser, but not navigate anywhere:

WebUI.openBrowser()

You would then be able to mess around with that window manually, then run a script against it by right-clicking on a line of code in your script, then clicking Run from here > your browser instance.

In any case, I believe you will need a Katalon-generated browser instance.

1 Like

well then its problematic …

From what I can find, a feature like this was requested, but ultimately abandoned by the Selenium team:

I’ve read a couple articles claiming that it’s possible, like this one for example:

https://www.google.com/amp/www.teachmeselenium.com/2018/08/11/how-to-connect-selenium-to-an-existing-browser-that-was-opened-manually/amp/

But it looks like quite a hack to finagle with.

1 Like

thank you so much for sparing your time for this. I will this hack … i have one more urgent doubt if u cud help me with . I wanna handle this alert
multipleDownload%20Alert

In the same fashion as my response to your other question:

try adding the following property:

image

1 Like

Sure . Iwill try and post the result… Thanks

Hi Brandon, I tried this setting for the below issue but its not working , I have made exact setting suggested by you , but it doesn’t seems to work.

image

My settings…

image

I actually spent a good portion of my day on this as well. The desired capability I recommended has worked for me in the past, but fails on the most current version of Chrome…

This is actually quite a rabbit hole, but here we go:

There was a change made in 2013 as to how Chrome handles multiple download requests for a single session on a website. My guess is that it was for security reasons. I can imagine that if a user wasn’t notified of multiple files being downloaded from a single click, a dubious character could sneak some pretty nasty stuff in there.

That popup is the result. The problem is, they keep changing how the “Allow” or “Block” setting is stored every couple of years, which makes pinning down the right Desired Capability a moving target. The solution I proposed used to work:

profile.default_content_settings.popups = 0

but it looks like it’s changed once again. I’ve tried a couple of other ones, but the most recent solution I could find didn’t work.

The only other workaround (that I can confirm works) is to refresh the browser right after the first file is downloaded using:

WebUI.refresh()

Beyond that, hopefully we’ll hear something from the Chrome devs about this at some point :face_with_raised_eyebrow:

1 Like

For anyone else who finds this, I use the following Keyword setup:

/**
 * Connect to a chrome client with --remote-debugging-port enabled
 *
 * @param port  the chrome client's remote debugging port
 * @return      a WebDriver connected to the chrome client
 */
@Keyword
public static WebDriver connectToRunningClient(int port = 9222) {
	// Get path to Katalon's chromedriver
	String chromeDriverPath = DriverFactory.getChromeDriverPath()

	// Set up the chromedriver path
	System.setProperty("webdriver.chrome.driver", chromeDriverPath)

	// Set the host and port of the running chrome instance
	ChromeOptions options = new ChromeOptions();
	options.setExperimentalOption("debuggerAddress", "localhost:$port");

	// Create the chromedriver
	WebDriver driver = new ChromeDriver(options);

	// Change Katalon's default chromedriver to this one
	DriverFactory.changeWebDriver(driver)

	return driver
}

Setup

1. Launch chrome in remote debugging mode

You’ll want to launch chrome using the --remote-debugging-port flag, e.g.:

$ /path/to/chrome --remote-debugging-port=9222

2. Call the keyword at the beginning of your script

CustomKeywords.'com.your.package.connectToRunningClient'()

// Verify that we successfully connected by printing the title
title = WebUI.getWindowTitle()
KeywordUtil.logInfo("Title: $title")

Et voila! You can now run scripts that connect to your launched browser. I like to use this for larger Test Cases where I don’t want to have to run through the whole thing to test step 285 :sweat_smile: I’ll create some temporary test case, connect it to a launched chrome session that’s already at step 284, and then test the new step. Once I’ve verified it’s working, I’ll add it to the the actual test case :smiley:

1 Like