TestProject Forum
Powered by leading experts in the test automation community

Comparing values of table td with integer using selenium?

I need to compare a value of

tag with an Integer value. I need to check if the value in that td is greater/less than another value.


<td class="ascending">20</td>

I would like to verify that 20 is < given number.

I know there is a sorting method on

. I could test the sorting process. So I thought to sort in ascending and compare the first value with the boundary value and again sort in descending order and compare again.

Is it possible to achieve with selenium ?

You could try using findElements to find all

tags that match your criteria, and then getText method to get each element value. The value will be returned as a String, so you will need to convert it to int before the comparison.

You would probably want to use findElements with a CSS selector since the sorted elements have a unique class.