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
Asked
Active
Viewed 366 times
-3
-
i updated the question please have a look ? – user3658696 Jun 27 '14 at 12:52
-
if you know seleniumWebdriver then you already know what i mean. – user3658696 Jun 27 '14 at 12:53
1 Answers
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