In Katalon Studio, I have a form that has a dynamic number of checkboxes. I need to click on all checkboxes.
I tried the below, but it only clicks on the first checkbox:
TestObject agreement = new TestObject().addProperty('css', ConditionType.EQUALS, 'input[type="checkbox"]')
for (def index : (0..0)) {
WebUI.click(agreement)
}
Any help?
Thank you
You cannot do this directly with TestObject
.
You need WebElement
s for the checkboxes. Don't worry: you can convert them back into TestObject
s, so you can still use those built-in WebUI
keywords on them...
Here, try this:
DriverFactory.getWebDriver()
.findElements(By.css("input[type = 'checkbox']"))
.collect { WebElement checkboxEl -> return WebUI.convertWebElementToTestObject(checkboxEl); }
.each { TestObject checkbox ->
WebUI.scrollToElement(checkbox, 2);
WebUI.click(checkbox);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.