how many results are from www.seleniumhq.org are displayed in the first 10 results

StackOverflow https://stackoverflow.com/questions/20867850

  •  23-09-2022
  •  | 
  •  

質問

I am new to Selenium Remote Control (RC). My requirement is that I have to search Selenium from Google and find out how many results from www.seleniumhq.org are displayed in the first 10 results.

I tried:

int count = selenium.getXpathCount(
  "xpath=//a[contains(@href,'www.seleniumhq.org')]"
).intValue();

But it gives the wrong count, since its counted links below www.seleniumhq.org; e.g download, selenium documentation, etc.

Correct count should be 2 since there is only 2 links which contains www.seleniumhq.org:

  1. www.seleniumhq.org
  2. www.seleniumhq.org/download/‎

Please suggest the solution.

役に立ちましたか?

解決

You can try belo not tested but something like this should work. I am checking if the attributes are present and your check then provide the count.

 int count= selenium.getXpathCount("xpath=//a[@onmousedown and @href and @data-cthref and contains(@href,'www.seleniumhq.org')]").intValue();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top