0

I have to create one selenium script for testing if website search is working fine or not. On searching any content, results are displayed. But on UI no tags are displayed which i can capture for validation. Please suggest an approach for validating if search results are correctly displayed.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
shruti
  • 33
  • 1
  • 6
  • Ideal solution will be create a xml reusable parsing class which contains all of the strings which you want to search. Reference [http://stackoverflow.com/questions/25746375/selenium-webdriver-reusable-xml-parsing-class-method-is-not-working-due-to-ret] and then CREATE TWO XML files first one will contain 1) Items to be searching 2) Expected Result and then use assert function to validate the result can get reference from [http://stackoverflow.com/questions/13226986/how-to-verify-a-text-present-in-the-loaded-page-through-webdriver] – Abhinav Kumar Singh Sep 15 '14 at 11:43

1 Answers1

0

You can take the entire search results in a List, iterate through each element in the list and validate whether it is correct or not depending on the initial few starting characters[words] of the word[sentence]

Rishi Khanna
  • 409
  • 1
  • 5
  • 16
  • Thanks Rishi for replying. Validating with respect to snippet is one way. But sometimes, few results are displayed for which snippet is not present on the search result page. I was just trying to make the test more generic. Please suggest if there is any other alternative. – shruti Sep 15 '14 at 07:06
  • I cannot think of anything else, but the keyword used in the search text box should be part of the search results, this means it can be either show up as complete search text or it should be a part of string. – Rishi Khanna Sep 15 '14 at 07:27