以下是我的断言。
Assert.assertEquals(securityQuestionPage.UserName.getText().toString(),BaseClass.unsuccessfulpassword);
我想根据Assertion的结果使测试用例失败/通过。
如果断言失败:
test.fail("description", takescreenshot)
如果传递断言
test.pass("passed",takeScreenshot)
不使用if语句,我可以使用ternary
运算符这样的断言。
有这样的吗?
Assert.AsserEquals(locator.getText(), expectedMessage,test.pass(""),test.fail())
答案 0 :(得分:1)
您可以使用 try-catch 块:
try{
Assert.assertEquals(securityQuestionPage.UserName.getText().toString(),BaseClass.unsuccessfulpassword);
// Now if the above line is correct then flow will not go to catch block followed by line just after this line.
test.pass("passed",takeScreenshot)
}
catch(Exception e){
test.fail("description", takescreenshot)
}