Pages

How To Handle Dynamic Web Table In Selenium WebDriver

If web table has same number of rows and same number of cells In each rows every time you load page then It Is very easy to handle that table's data In selenium WebDriver software testing tool as described In How To Extract Table Data/Read Table Data Using Selenium WebDriver post. Now supposing your table's rows and columns are increasing/decreasing every time you loading page of software web application or some rows has more cells and some rows has less cells then you need to put some extra code In your webdriver software test case which can retrieve cell data based on number of cells In specific row. Consider the dynamic webtable shown In bellow given Image.

In this table, Row number 1, 2 and 4 has 3 cells, Row number 3 has 2 Cells and Row 5 has 1 cell. In this case, You need to do some extra code to handle these dynamic cells of different rows. To do It, You need to find out the number of cells of that specific row before retrieving data from It.