Count items, rows, users, etc in Katalon Studio Count items, rows, users, etc in Katalon Studio selenium selenium

Count items, rows, users, etc in Katalon Studio


You can also use WebUiBuiltInKeywords to findWebElements as specified in the following URL. It will return a list of elements matching the locator.

static List<WebElement> findWebElements(TestObject to, int timeOut)// Internal method to find web elements by test object

Examples

def elements = WebUiBuiltInKeywords.findWebElements(to, 5)println elements.size()


I think you can use the same method of size() like done in Table:

See documentation.

import org.openqa.selenium.By as Byimport org.openqa.selenium.WebDriver as WebDriverimport org.openqa.selenium.WebElement as WebElementWebDriver driver = DriverFactory.getWebDriver()'To locate table'WebElement Table = driver.findElement(By.xpath("//table/tbody"))'To locate rows of table it will Capture all the rows available in the table'List<WebElement> rows_table = Table.findElements(By.tagName('tr'))'To calculate no of rows In table'int rows_count = rows_table.size()println('No. of rows: ' + rows_count)

Hope this helps you!


Do this

WebDriver driver = DriverFactory.getWebDriver()def eleCount = driver.findElements(By.className("your-class")).size()println eleCount //prints out the number of the elements with "your-class" class