我应该导入哪个类才能使用 verifyTrue
我使用 Selenium 和 TestNG 使用 dataProvider。我正在验证有一百个名字的列表。我已将所有这些添加到 Excel 工作表中,并在单元格中以逗号分隔。我用 Java 编程如下:
import static org.testng.AssertJUnit.*;
public class example extends Base{
@Test(dataProvider="List")
public void isListofNamesPresent(String names) throws Exception
String list[] = names.split(",");
for(int i=0; i<list.length; i++){
assertTrue(selenium.isTextPresent(list[i]));
Reporter.log("Type of Case:"+ names +" are present");
}
}
上面的代码断言放入 CELL 中的名称列表为(Aaron、James、Jack、Hegin、Henry)。由于它只有一轮数据,因此如果出现任何错误,它将退出该方法由于assertTrue,实际值与预期值之间存在差异。如果我给出 verifyTrue 那么它应该执行所有列表,即使实际和预期之间存在不匹配。
谁能告诉我如何使用 verifyTrue 吗?我的意思是我需要导入哪个类。我无法扩展任何课程,因为我已经扩展了基础课程。所以任何导入都可以。我尝试使用 SeleneseTestCase 但没有运气。
提前致谢
I am using Selenium with TestNG using dataProvider. I am verifying the list which have hundred names. I have added all of these into an excel sheet with comma separated in A CELL. I have programmed in Java as below:
import static org.testng.AssertJUnit.*;
public class example extends Base{
@Test(dataProvider="List")
public void isListofNamesPresent(String names) throws Exception
String list[] = names.split(",");
for(int i=0; i<list.length; i++){
assertTrue(selenium.isTextPresent(list[i]));
Reporter.log("Type of Case:"+ names +" are present");
}
}
The above code asserts the list of names which are put in A CELL as (Aaron, James, Jack, Hegin, Henry).Since it has only one round of data it exits the method if any error between actual and expected because of assertTrue. If i give verifyTrue then it should get execute all the list even though there is a mismatch between actual and expected.
Can anyone please tell me how to use verifyTrue? I mean which class i need to import. I cannot extend any class as I have already extended a Base Class. So any import will do. I tried with SeleneseTestCase but no luck.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种方法是创建您自己的
verifyTrue()
方法,该方法执行类似以下操作来捕获断言错误:Another way you can do it would be to create your own
verifyTrue()
method that does something like this to catch the assert error:您可以导入 SeleneseTestBase 类来使用 verifyTrue() ,如下所示:
也可以使用 SeleneseTestCase,但它已被弃用。所以。最好使用 SeleneseTestBase
You can import SeleneseTestBase class to use verifyTrue() as below:
SeleneseTestCase can also be used, but it is deprecated. So. it is better to use SeleneseTestBase