Selenium - How to count the number of rows in a table?

孤人 提交于 2019-12-04 13:00:46

To store Number of rows into table you can use storeXpathCount

storeXpathCount | id=listBalances | NumberOfRows
echo  | ${NumberOfRows}

storeXpathCount will store rows count into variable NumberOfRows And echo will return count.

I would suggest the following:

1) make list of elements of your table (e.g if you need to count your row count then select any row using appropriate selector).

2) then create list of web elements

List<WebElement> columnElments = driver.findElements(By.cssSelector("...blablabla..."));
int rowNumer = columnElmments.size();

or either:

@FindBy
            (how = How.CSS, using = "blablablba")
List<WebElement> col;

int rowNumer =col.size();

Hope you got the idea

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