Quality Testing

Quality is delighting customers

Which command will use to count the number of rows of a table using Selenium IDE?

Hi All,

 

Which command will use to count the number of rows of a table using Selenium IDE?

 

Can any one answer to this question.

 

~Sri

 

 

Views: 3811

Reply to This

Replies to This Discussion

Hi Vidhya,

 

There is a method in Selenium IDE and Selenium RC called "assertXpathCount() for IDE, getxpathcount() for RC" to get the number of rows and columns which satisfies the given Xpath.

 

Please let me know if you have any doubts.

Thanks

Santhosh.

selenium.getXpathCount("//xpath to table"//tr);

So, if I had a table with an id of "toptable, I could do the following...

int i = selenium.getXpathCount("//table[@id='toptable']//tr");

 

That should return the number of rows in the table. An even better way is to write a method that will get the number of rows in the table, or the number of columns for a given row. You could write those methods yourself and add them as part of your library. Such as...

 

public int GetRowCount(String tableXpath)

{

    return selenium.getXpathCount("//table[@id='tableXpath']//tr");

}

 

public int GetColumnCount(String tableXpath, int row)

{

    return selenium.getXpathCount("//table[@id='tableXpath']//tr[row]//td");

}

 

of course, don't forget to add error handling in case the xpath can not be found.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service