-2

Basically am getting the data from excel and in my excel i have a column named as execution and there is around 10 data's in my excel and if i made "yes" on respective data that data will execute.

suppose in excel i made 3 "yes". first "yes" data got passed and second "yes" data got failed so third "yes" data is not executing.

in baseclass i annoted two method "open browser" and "close browser" as beforesuite and aftersuite.

kindly help me on this.

closed as unclear what you're asking by Moro, c32hedge, IAmMilinPatel, Bharat Mane, NarendraC Oct 11 at 13:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This would be a good question if you were to update your question with the layout of your excel spreadsheet, the code you're using, and the errors you are receiving. The information you provided in the answer is good, but without your code nobody here could have helped you. – Kate Paulk Oct 10 at 12:31
  • The question and answer don't even seem related. The question is about continuing on testcase failure, and the answer is about handling exceptions for alerts? – anonygoose Oct 10 at 16:16
0

This is happening because of the default behaviour of the driver when it encounters an alert. The default behaviour was set to ACCEPT, thus the alert was closed automatically, and the switchTo().alert() couldn't find it explicitly.

The solution is to modify the default behaviour of the driver to IGNORE, so that it doesn't close the alert but just ignores it:

DesiredCapabilities dc = new DesiredCapabilities();

dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);

d = new chromedriver(dc);

Then you can handle it easily and use the try-catch exception handling code to catch an error if any:

try {

    click(myButton);

} catch (UnhandledAlertException f) {

    try {

        Alert alert = driver.switchTo().alert();

        String alertText = alert.getText();

        System.out.println("Alert data: " + alertText);

        alert.accept();

    } catch (NoAlertPresentException e) {

        e.printStackTrace();

    }

}

Not the answer you're looking for? Browse other questions tagged or ask your own question.