title: Selenium Java - Getting the list of urls from google search and taking a count match of a specific url text
body: <p>I am looking for a logic/code which will enter text <em>selenium</em> in google.com and from the search results it will fetch the first 10 urls list and from this list it will count which urls start with <em>www.seleniumhq.org</em>.</p>
  
  <p>So far my code is able to display the first 10 urls list:</p>
  
  <pre><code>public static WebDriver driver;
  
  public static void main(String[] args) throws InterruptedException {
      driver = new FirefoxDriver();
      String url = "https://google.com";
      driver.get(url);
      WebElement find = driver.findElement(By.id("lst-ib"));
      find.sendKeys("Selenium");
      Thread.sleep(2000);
      WebElement click = driver.findElement(By.name("btnG"));
      click.click();
      Thread.sleep(2000);
      List&lt;WebElement&gt; listings = driver.findElements(By.tagName("div").xpath("//cite[@class='_Rm']"));
      listings.size();
      System.out.println("Fetched URL's are as follows:-");
  
      for (WebElement loop : listings) {
          System.out.println(loop.getText());
  
          String filtering=loop.getText();
          boolean filtered=filtering.startsWith("www.seleniumhq.org/");
  
          int size1 = filtering.split("www.seleniumhq.org").length-1;
  
          System.out.println(size1);
      }
  }
  </code></pre>
  
  <p>Any help ?</p>