以下是我的断言。
Assert.assertEquals(securityQuestionPage.UserName.getText().toString(),BaseClass.unsuccessfulpassword);
我想根据断言的结果使测试用例失败/通过..
如果断言失败:
test.fail("description", takescreenshot)
如果断言通过
test.pass("passed",takeScreenshot)
不使用if语句,我可以有像三元
运算符这样的断言吗?
有类似的吗?
Assert.AsserEquals(locator.getText(), expectedMessage,test.pass(""),test.fail())
最佳答案
您可以使用try-catch block :
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)
}
关于java - 截取 Selenium 中断言的屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50924709/