[英]How to use Selenium webdriver to execute test cases in Testlink
[英]How to use assertion with test while executing tests in testlink
我正在使用Java在Selenium中創建測試,並使用testlink進行測試執行和結果。沒有斷言,測試可以與testlink一起正常工作並顯示結果,但是當我使用斷言來驗證預期和實際結果時,如下所示:
try {
driver.get("http://www.software-testing-tutorials-automation.com");
String ExpextedTitle="Software testing tutorials and automatio";
String ActualTitle=driver.findElement(By.xpath("//h1[@class='title']")).getText();
Assert.assertEquals(ActualTitle, ExpextedTitle);
IntegrationWithTestLink.updateResult("GR-1", null, TestLinkAPIResults.TEST_PASSED);
}catch(Exception e){
System.out.println("Hiiiii");
IntegrationWithTestLink.updateResult("GR-1", e.getMessage(), TestLinkAPIResults.TEST_FAILED);
}
}
我不知道為什么測試鏈接中未顯示結果以防萬一。 誰能建議我在這里使用斷言的更好方法。
斷言錯誤沒有被catch塊捕獲,因為您正在捕獲的異常不是錯誤。 要捕獲錯誤,請更改代碼,如下所示。
嘗試{
driver.get("http://www.software-testing-tutorials-automation.com");
String ExpextedTitle="Software testing tutorials and automatio";
String ActualTitle=driver.findElement(By.xpath("//h1[@class='title']")).getText();
Assert.assertEquals(ActualTitle, ExpextedTitle);
IntegrationWithTestLink.updateResult("GR-1", null, TestLinkAPIResults.TEST_PASSED);
}catch(AssertionError e){
System.out.println("Hiiiii");
IntegrationWithTestLink.updateResult("GR-1", e.getMessage(), TestLinkAPIResults.TEST_FAILED);
}
}
它可能為您工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.