嗨很容易寫測試用例結果通過/失敗使用硒與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