How to get the current instance of webdriver? Is there any method/keyword like getDriver()?

I am creating a custom keyword and it needs webdriver instance. Is there any keyword or method such as getDriver.

Thank you Marek :slight_smile:

Hello, try following code:

import com.kms.katalon.core.webui.driver.DriverFactory as DF

def driver = DF.getWebDriver()

1 Like

Good stuff I used something similar to this in an old post:

import org.openqa.selenium.By
import org.openqa.selenium.WebElement

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.WebDriver


// get the text of the body element
WebDriver driver = DriverFactory.getWebDriver();
WebElement body = driver.findElement(By.tagName("body"));
String bodyText = body.getText();

// count occurrences of the string
int count = 0;

// search for the String within the text
while (bodyText.contains("Google")){

    // when match is found, increment the count

    // continue searching from where you left off
    bodyText = bodyText.substring(bodyText.indexOf("Google") + "Google".length());

countIs = count.toString()


I was replying to this: Looking for duplicate links in a page