title: How many times a text appears in webpage - Selenium Webdriver
body: <p>Hi I would like to count how many times a text Ex: "VIM LIQUID MARATHI" appears on a page using selenium webdriver(java). Please help.</p>
  
  <p>I have used the following to check if a text appears in the page using the following in the main class </p>
  
  <p><code>assertEquals(true,isTextPresent("VIM LIQUID MARATHI"));</code></p>
  
  <p>and a function to return a boolean</p>
  
  <pre><code>protected boolean isTextPresent(String text){
      try{
          boolean b = driver.getPageSource().contains(text);
          System.out.println(b);
          return b;
      }
      catch(Exception e){
          return false;
      }
  }
  </code></pre>
  
  <p>... but do not know how to count the number of occurrences...</p>