2
public static String driverPath = "C:/";
public static WebDriver driver;


@BeforeTest
public void Circulars() throws Exception  {

    ExcelUtils.setExcelFile("C://TestData//TestData.xlsx", "Sheet1");

    String username = ExcelUtils.getCellData(1, 1);   
    String password = ExcelUtils.getCellData(1, 2); 

    driver = WebPortalLogin.login(username, password);

    circulars(driver);
    option_list(driver);
    close_browser();

}

@Test
public void circulars(WebDriver driver)     {

    WebPortalNGFile.communication(driver).click();
    WebPortalNGFile.circulars(driver).click();

}

@Test
public void option_list(WebDriver driver)       {

    WebPortalNGFile.communication(driver).click();
    WebPortalNGFile.option_list(driver).click();

}

@Test
public void close_browser()    {
    driver.close();

}

3 Answers 3

1

You want to catch the exception. Although, if an exception is being thrown there is likely a good reason and you should do everything you can to prevent it and handle the error more appropriately than ignoring it.

try {
    // call your method
}
catch {
    // do nothing
}
0

You could use

   for (int i = 0; i < 10; i++) {
    try {

      // call your Test method 
    }
    catch {
        // after catching exception use continue statement
     continue;
      }
    }

@AfterClass
public void close_browser()    {
    driver.close();

}
0

In case you don't know where an exception can occur you can use throws instead of try/catch.

return_type method_name() throws exception_class_name{  
//code  
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.