Browser instance in Katalon studio

Hi,
In the katalon studio, whenever we are creating the driver object by openBrowser() method, then while creating the keyword, how this created object is carried forward from one class to another class while nowhere we are creating the driver object?
Could anyone please explain the same?

Thanks and regards,
Swati Sachan

Keeping this REALLY simple (because it would take too long otherwise)…

When you write a Test Case script, your TC is in fact a Groovy “Script Class”. It is “owned” by the Katalon runtime executor.

When you call openBrowser, the executor class keeps a reference to the driver in its member variables.

Everything you do “next” happens “inside” the executor where it has a whole bunch of references to the things you create(d).

In short, your code runs in the scope of the Katalon executor.

2 Likes

To build on what @Russ_Thomas has said, if you open a browser using WebUI.openBrowser(), then Katalon Studio will instantiate a WebDriver object and place it in a list with a static, thread-safe reference. Then, whenever that driver is needed for any action, it is retrieved from this list.

In the case that you are using a built-in WebUI keyword, such as (WebUI.navigateToUrl(), WebUI.click(), etc.), then that keyword will grab the driver instance for you behind the scenes.

In the case that you want to implement your own keyword, you can retrieve the instance that was created like so:

WebDriver driver = DriverFactory.getWebDriver()

Hopefully that answers your question.

2 Likes

Thank you so much for your response, yes, i got it now the functionality of the Web driver behind the scene. :slight_smile: