Skip to main content

Running Groovy Script In Katalon With LambdaTest Selenium Grid

As you perform testing with Katalon Studio, you can write or edit test automation scripts in the Script mode using Groovy programming language. This tutorial will help you run your Groovy script in Katalon with LambdaTest Selenium Grid.

Step 1: Open your Katalon Studio instance & go to Tests Explorer from the left side-bar.

Step 2: Right-click on the Test Listener folder & click on the new listener.

Step 3: Name the new listener & paste the below code in the new listener.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import as Mobile

import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.annotation.TearDown
import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.context.TestCaseContext
import com.kms.katalon.core.context.TestSuiteContext

import com.kms.katalon.core.webui.driver.ExistingRemoteWebDriver

import com.kms.katalon.core.configuration.RunConfiguration

class LambdaListener {

TestSuiteContext suiteContext;

* Executes before every test case starts.
* @param testCaseContext related information of the executed test case.
def sampleBeforeTestCase(TestCaseContext testCaseContext) {

//To set the test name at LambdaTest.
RunConfiguration.setDriverPreferencesProperty("Remote", "name", testCaseContext.getTestCaseId());
if (suiteContext != null){
RunConfiguration.setDriverPreferencesProperty("Remote","build", suiteContext.getTestSuiteId());
println testCaseContext.getTestCaseId();
println RunConfiguration.getDriverPreferencesProperties();
* Executes after every test case ends.
* @param testCaseContext related information of the executed test case.
def sampleAfterTestCase(TestCaseContext testCaseContext) {
//To set the status of test at LambdaTest.
String result="failed";
}catch (Exception e)
println e.toString()
finally {
println testCaseContext.getTestCaseId()
println testCaseContext.getTestCaseStatus()

* Executes before every test suite starts.
* @param testSuiteContext: related information of the executed test suite.
def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
//To Set the build Name at LambdaTest.
RunConfiguration.setDriverPreferencesProperty("Remote","build", suiteContext.getTestSuiteId());
println testSuiteContext.getTestSuiteId()

* Executes after every test suite ends.
* @param testSuiteContext: related information of the executed test suite.
def sampleAfterTestSuite(TestSuiteContext testSuiteContext) {
println testSuiteContext.getTestSuiteId()

That is all. Now, you can effortlessly run Groovy Scripts in Katalon for triggering your tests over LambdaTest cloud-based cross browser testing platform. Happy testing! 🙂