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

醉酒当歌 提交于 2019-12-24 10:24:15

问题


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);

回答1:


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...


来源:https://stackoverflow.com/questions/55655250/converting-a-java-code-containing-selenium-commands-to-groovy-in-order-to-be-ins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!