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


in html page there's table 10 rows; rows display based on filter (dynamically). let's say, example, without filters default 10 row returned. after applying filter, less 10 rows returned, depending on type of filter, want dynamic count of table rows (after filter) using selenium web driver.

i tried driver.findelements(by.xpath("abcd")).size() giving default count 10; however, after applying filter 2 rows appearing.

please suggest how dynamic count (count=2 appearing 2 rows in ui) .

to find total number of elements on dynamic webpage need use driver.findelements().size() method. it's not useful @ all.

first size of element matching row count. once have can use dynamic xpath ie replace row , column number run time data.

{     list<webelement> rows_table = mytable.findelements(by.tagname("tr"));     //to calculate no of rows in table.     int rows_count = rows_table.size();      //loop execute till last row of table.     (int row=0; row<rows_count; row++){     //to locate columns(cells) of specific row.     list<webelement> columns_row = rows_table.get(row).findelements(by.tagname("td"));     //to calculate no of columns(cells) in specific row.     int columns_count = columns_row.size();     system.out.println("number of cells in row "+row+" "+columns_count);      //loop execute till last cell of specific row.     (int column=0; column<columns_count; column++){     //to retrieve text specific cell.         string celtext = columns_row.get(column).gettext();         system.out.println("cell value of row number "+row+" , column number "+column+" "+celtext);     }     system.out.println("--------------------------------------------------"); } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -