title: Verify an error message using selenium web driver
body: <p>I want to verify the error message displaying after login failed. Specifically, I want to verify the text with &quot;Invalid username or password&quot;.</p>
  <p>This is the html code.</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;statusMsg&quot;&gt;
    &lt;div class=&quot;alert in fade alert-error&quot; style=&quot;opacity: 1;&quot;&gt;
      &lt;a class=&quot;close&quot; data-dismiss=&quot;alert&quot;&gt;×&lt;/a&gt;
        Invalid username or password
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>This is the code I tried.</p>
  <pre class="lang-java prettyprint-override"><code>String actualMsg=driver2.findElement(By.xpath(&quot;//div[@id='statusMsg']/div&quot;)).getText()
  String errorMsg= &quot;× Invalid username or password&quot;;
  
  if(actualError.equals(errorMsg)) {
      System.out.println(&quot;Test Case Passed&quot;);
  }else{
      System.out.println(&quot;Test Case Failed&quot;);
  };
  </code></pre>
  <p>The output is always &quot;Test Case Failed&quot;.</p>
  <p>Is There a way to fix this?</p>