title: How to assert elements contains text in Selenium using JUnit
body: <p>I have a page that I know contains a certain text at a certain xpath. In firefox I use the following code to assert that the text is present:</p>
  
  <pre><code>assertEquals("specific text", driver.findElement(By.xpath("xpath)).getText());
  </code></pre>
  
  <p>I'm asserting step 2 in a form and confirming that a certain attachment has been added to the form.
  However, when I use the same code in Chrome the displayed output is different but does contain the specific text. I get the following error:</p>
  
  <pre><code>org.junit.ComparisonFailure: expected:&lt;[]specific text&gt; but was:&lt;[C:\fakepath\]specific text&gt;
  </code></pre>
  
  <p>Instead of asserting something is true (exactly what I'm looking for) I'd like to write something like:</p>
  
  <pre><code>assert**Contains**("specific text", driver.findElement(By.xpath("xpath)).getText());
  </code></pre>
  
  <p>The code above does not work obviously but I can't find how to get this done.</p>
  
  <p>Using Eclipse, Selenium WebDriver and Java</p>