-3

How can i check using selenium web driver either any search result exists or not. e.g while searching any record in the amzon.de

user3658696
  • 31
  • 1
  • 1
  • 5

1 Answers1

1

You don't have to deal with the result_count if you are interested only in the first element. You only need to select it, using the right xpath. The first result has id="result_0"

This should work:

//div[@id="result_0"]/h3/a/span
George Ant
  • 371
  • 1
  • 6
  • thanks for the answer, actually problem is not to click on the first record problem is to check is record count is greater than one or not. Because in result count there is a string and inorder to make a check on it it should be Numeric. – user3658696 Jun 27 '14 at 19:35
  • You want `record_count > 1`. You can check this by locating the second element. If second element exists, then `record_count>1`. If second element doesn't exist, then `record_count<=1`. There are many ways to implement this. You can use the xpath on my answer and just change the `result_0` to `result_1`, or you can use `driver.findElements( By.id("result_1") ).size() != 0` – George Ant Jun 28 '14 at 15:09