0

I have to compare a value of a td tag with a numeric value. I have o check whether the value coming in that td is >= some value. The html of td is:

<td class="sorting_1">78000</td>

I want to compare that the value 78000 >=75000. Basically there is a sorting method on th. So I have to test the sorting process, So I thought to sort in ascending and comparing the first value with the boundary value and again sorting in desc and doing same comparison.

How to do this in webdriver?

4

You can use the findElements method to find all TD tags that match your criteria, and then getText method to retrieve each element's value. The latter will be returned as a String, so you may need to convert it to a number before comparing it.

Since the sorted elements have a special class, you may want to use a CSS selector with findElements.

| improve this answer | |
  • Hey thanks for confirming this. I was thinking the same but was not sure whether that is right approach or do we have any special class in webdriver for this. It was helpful. And by the way I do have some specific class applied on sorting like asc and desc. So I will use them too. Thanks @user246. – Ashwani Raj Jun 27 '14 at 5:29
  • Yes you did, I'll update my answer. – user246 Jun 27 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.