我想验证登录失败后显示的错误消息。我总是收到我尝试过的“测试用例失败”。
我想用“无效的用户名或密码”来验证文本。下面是我试过的代码。
这是html代码。
<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>
Run Code Online (Sandbox Code Playgroud)
这些是我试过的代码。
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");
};
Run Code Online (Sandbox Code Playgroud)
输出总是“测试用例失败”。
有没有办法来解决这个问题?