问题描述
对于Java环境中使用Selenium Webdriver的特定问题,我有解决方案,因此,我想将Java和Java中的代码放在运行常规语言的脚本模式下的Katalon中,下面提供的代码包含诸如findElements的硒命令.size()来计算面板中的元素,而我在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);
推荐答案
在使用Selenium命令之前,您需要切换驱动程序,请使用此命令(对于Chrome):
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...
这篇关于将包含硒命令的Java代码转换为Groovy,以便在Katalon上的脚本模式下插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!