嗨很容易写测试用例结果通过/失败使用硒与testng框架,请阅读下面的链接我已经给出了明确的例子。
How can I write Test Result (Pass/Fail) in Excel file using TestNG Framework with Selenium WebDriver?
更多具有实时的例子,你可以阅读write test case pass/fail in excel using testng
只要你必须创建的FileInput流和FileOutputStream中的类Excel的工具如下并调用该类到使用另一个类extends关键字
的Excel工具:
public class Excelutility {
@BeforeTest
public void exceloperation(){
FileinputStream file = new FileiinputStream("file path");
//do file input stream details here
Fileoutputstream newfile=new Fileoutputstream("filepath");
//do fileoutputstream details here like create workbook,create sheets etc
}
}
另一个CLA ss:
public class operations{
@Test
public void openbrowser(){
//write driver operations here
//write excel operations using
if(Title.equalsIgnoreCase("HP Loadrunner Tutorial")){
Testcase="PASS";
}else{
Testcase = "FAIL";
}
Label l1=new Label(1,2,"status")
writablesh.addCell(l3);
}
谢谢。但如何使硒显示失败,或通过? – aemy
你可以发布你的代码吗? – Brainles71
已经更新我的回答。代码仍然有帮助 – Brainles71