Java Selenium WebDriver代码以实现验证而不是断言 [英] Java Selenium WebDriver code to implement Verify instead of Assert
问题描述
我无法理解如何编写Java代码来实现Verify
.我总是看到实现Assert
的代码,但没有实现Verify
的代码.我知道对于Assert
,我们需要编写如下代码:
I am not able to understand how to write Java code to implement Verify
. I am always seeing the code to implement Assert
but not for Verify
. I know for Assert
, we need to write the code as below:
Assert.assertTrue()
或
Assert.assertEquals() etc.
但是Verify
呢?用户使用verify
登录到应用程序后,我想验证应用程序的标题.我该怎么办?
But what about Verify
? I want to verify the title of my application once the user is logged into the application by using verify
. How can I do this?
推荐答案
您必须使用仅支持Assert语句的TestNG框架.它不支持验证语句.您可以访问TestNG Javadoc的以下URL:
You must use the TestNG framework which only supports Assert statements. It doesn't support Verify statements. You can visit the following URL for TestNG Javadoc:
来自当断言失败时,将跳过该行代码之后的所有测试步骤 当验证"失败时,测试将继续执行并记录失败.
When Assertion fails all test steps after that line of code are skipped When a "verify" fails, the test will continue executing and logging the failure.
如果要使用Verify语句,则必须使用Junit框架.
If you want to use Verify statements then you will have to use the Junit framework.
这篇关于Java Selenium WebDriver代码以实现验证而不是断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!