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.
如果要使用验证语句,则必须使用 Junit 框架.
If you want to use Verify statements then you will have to use the Junit framework.
这篇关于Java Selenium WebDriver 代码来实现验证而不是断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!