Seleniumでは、テストケースでステップが失敗した場合、失敗を報告して残りのステップを続行できますか?現在、例外が存在する場合、実行は停止します。これは私のテストケースがSeleniumでは、テストケースでステップが失敗した場合、失敗を報告して残りのステップを続行できますか?
public class TC002_abc extends OpentapWrappers
{
@Test (description="Test")
public void main()
{
try
{
WebDriverWait wait=new WebDriverWait(driver, 60);
VerifyTitle(Constant.HomePage_Title);
Click(HomePage.link_Login(driver), "Login Link");
wait.until(ExpectedConditions.urlContains(Constant.LoginURL));
VerifyTextPopulated(CommunicationPref.lbl_EmailAddress_Input(driver), Constant.EmailAddress);
/* Validate Email Communications */
Click(CommunicationPref.link_EditEmailCommunications(driver),"Edit Email Communications");
VerifyText(CommunicationPref.lbl_UnCheckedEmailCommunications(driver), Constant.UnCheckedEmailCommunications_Text);
Click(CommunicationPref.btn_EmailCommunicationsSave(driver), "Save");
VerifyText(CommunicationPref.lbl_CheckedEmailCommunications(driver), Constant.CheckedEmailCommunications_Text);
}
catch (NoSuchElementException e)
{
e.printStackTrace();
Reporter.reportStep("NoSuchElementException" , "FAIL");
}
}
@BeforeClass
public void beforeClass()
{
browserName="firefox";
testCaseName = "TC002_abc";
testDescription = "Test";
}
}
サンプル法 -
public static void VerifyTitle(String title){
try
{
if (driver.getTitle().equalsIgnoreCase(title))
{
Reporter.reportStep("Page is successfully loaded :"+title, "PASS");
}
else
Reporter.reportStep("Page Title :"+driver.getTitle()+" did not match with :"+title, "FAIL");
}
catch (Exception e)
{
e.printStackTrace();
Reporter.reportStep("The title did not match", "FAIL");
}
}
ステップの一つは、それが結果を変える可能性があるので、他のステップは、その失敗したテストにdependednentされていないことを確認して失敗しない場合だけ、スローされる例外をキャッチ。テストを分割して、より管理しやすい小さなテストに分割することもできます。つまり、1つが失敗しても他のテストを続けることができれば、各テストは独立して実行できるはずです。 – redp
私は異なるTCについて話していません。同じテストケースで、私の4番目のステップが失敗して実行が中止し、残りのステップがスキップされたとすることができます。私はそれが4番目のステップの失敗を報告し、5番目のステップを実行し続けたい。出来ますか?現在、4番目のステップで例外がスローされた場合、その例外がキャッチされ、失敗が報告されますが、実行は継続されません。 –
TCはUI検証用です。だから、私は実行を途中で止めさせたくないだけです。要素の1つがページに見つかりませんでした。明らかでないことがあれば教えてください。 –