How to validate sorting results using selenium webdriver?


Actually my task is to sort the products by “Low” to “High” price wise.  And i wanted to check whether the displayed products are sorted correctly or not.  It will be good if you explain me with an example.

Kannan Default Asked on March 28, 2016 in Selenium WebDriver.
Add Comment
1 Answer(s)

Hey Kannan,

it is a nice questions. However sorting strings is not something that Selenium will help you do. You can rely on the Programming languages constructs to do this task. For example in java we can do a Arrays.Sort to sort out a string array.

So what you have to do is
1. Get all the product names in an array(Array1)
2. Apply sort
3. Apply sort on the web application
4. Again get all the names in a different array (Array2)
5. Compare the 2 arrays.

If you application is doing a simple name sort this will work.

Virender Singh Professor Answered on March 29, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.