Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|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 posting your answer, you agree to the privacy policy and terms of service.

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