Mohammad Dabbagh
Mohammad Dabbagh

Reputation: 31

Converting a java code containing selenium commands to groovy in order to be inserted at script mode on Katalon

I have a solution for a particular problem using Selenium Webdriver in Java environment, so the code in java and I want to put it in Katalon at script mode that runs groovy language and the code provided below contains selenium commands like findElements with. size() to count the elements in a panel which I did not find an equivalent for it in Katalon and also the code containing a casting from integer to string.

String changingselec = "";

int lastChildIndex = driver.findElements(By.cssSelector("body > app > div > manage-corr-app > div > div.flex-5.work-area-large > manage-user-recipient-groups > div > div.panel")).size();

changingselec = driver.findElement(By.cssSelector("body > app > div > manage-corr-app > div > div.flex-5.work-area-large > manage-user-recipient-groups > div > div.panel:nth-child(" + Integer.toString(lastChildIndex) + ")")).getText();

System.out.println(changingselec);

Upvotes: 1

Views: 358

Answers (1)

Mate Mrše
Mate Mrše

Reputation: 8444

Before using the Selenium commands you will need to switch driver, use this (for Chrome):

WebDriver driver = new ChromeDriver()
DriverFactory.changeWebDriver(driver)
// Continue with Selenium code...

Upvotes: 1

Related Questions