title: Using Selenium2, how do I check if certain text exists on the page?
body: <p>I am using the C# Selenium WebDriver and I would like to confirm that certain text exists on the page.</p>
  
  <p>How do I do this? All the selectors seem to use IDs, Classes etc. I don't care where the text is on the page, I just want to make sure it exists <em>somewhere</em> on the page.</p>
  
  <p>Any thoughts?</p>
  
  <p>PS: I can do this using JQuery and Javascript, but apparently that's not supported in all browser drivers:</p>
  
  <pre><code>protected bool TextIsOnThePage(string textToFind)
  {
      var javascriptExecutor = ((IJavaScriptExecutor)_driver);
      bool textFound = Convert.ToBoolean(javascriptExecutor.ExecuteScript(string.Format("return $('*:contains(\"{0}\")').length &gt; 0", textToFind)));
  
      return textFound;
  }
  </code></pre>