Comparing values of table td with integer using selenium ?

  • 1 Replies
  • 1045 Views
*

Karen

  • *
  • 17
Comparing values of table td with integer using selenium ?
« on: April 17, 2016, 20:23:28 pm »
I need to compare a value of <td> tag with an Integer value. I need to check if the value in that td is greater/less than another value.

HTML:
Code
<td class="ascending">20</td>

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

I know there is a sorting method on <th>. 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 ?

*

Oren

  • **
  • 59
Re: Comparing values of table td with integer using selenium ?
« Reply #1 on: April 18, 2016, 15:48:06 pm »
You could try using findElements to find all <td> 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.

 

Sitemap 1 2 3 4 5 6 7 8