katalon example Set For CountDynamicLooping
WebDriver driver = DriverFactory.getWebDriver()
def tutorialCheckCount(XXX) {
WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(By.xpath(('//*[@id=\''+XXX+'\']')))
List<WebElement> rows_table = Table.findElements(By.tagName('tr'))
return rows_table.size()
}
rows_count_outlet = tutorialCheckCount('tableID')
println(rows_count_outlet)
//---ActionLoop---------
for (i = 1; i <= rows_count_outlet; i++) {
pickSection = findTestObject('ObjectRepos', [('index') : i])
}
example i want take this table
inspect it and take the first of div with id unique on thats table..
at this case i get the div id unique is
"artdeco-modal-outlet"
this for how much we count object on thats table, now we need to take another object more spesific for how much we do action. at this time i take btn "connect"
//*[@id="artdeco-modal-outlet"]/div/div/div[2]/ul/li[1]/div/section/div[2]/footer/button/span
this is important.. save it into ur repo at katalon but change the value what hell will move if we change by indexing into another box, on this case is " li "
Now change the script set tagName web element is " li "
List<WebElement> rows_table = Table.findElements(By.tagName('li'))
and we already get the id artdeco-modal-outlet for we place it on table driver
def tutorialCheckCount(XXX) {
WebDriver driver = DriverFactory.getWebDriver()
WebElement Table = driver.findElement(By.xpath(('//*[@id=\'' + XXX + '\']')))
List<WebElement> rows_table = Table.findElements(By.tagName('li'))
return rows_table.size()
}
rows_count_member = tutorialCheckCount('artdeco-modal-outlet')
and for action we use looping
//---ActionLoop---------
for (i = 1; i <= rows_count_member; i++) {
selectConnection = findTestObject('Object Repository/btnConnectt', [('index') : i])
WebUI.click(selectConnection)
}
this for full script sample i have
should be have too for run
import org.openqa.selenium.By as By import org.openqa.selenium.WebDriver as WebDriver import org.openqa.selenium.WebElement as WebElement import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
now just the run katalon and there is should be click and loop depend how much table artdeco-modal-outlet have " li " element
here is short video of this from take element till run
*NOTES IF YO GETTING ERROR WHEN RUN THIS WAY, U CAN CHANGE FOR OBJECT REPOSITORY NEED TO BE LIKE THIS [${index}]