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