I am creating a custom keyword and it needs webdriver instance. Is there any keyword or method such as getDriver.
Thank you Marek
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
WebUI.openBrowser('https://www.google.com')
// 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
count++;
// continue searching from where you left off
bodyText = bodyText.substring(bodyText.indexOf("Google") + "Google".length());
}
countIs = count.toString()
WebUI.comment(countIs)
WebUI.closeBrowser()
I was replying to this: Looking for duplicate links in a page