Monday, 17 November 2014

Exception Handling

Exception Handling
An unexpected exception would be thrown if the worst case scenarios are not handled properly.Due to element not found or if the expected result doesn’t match with actuals, we should catch that exception and end the test in a Logical way that the script itself terminating abruptly.
Syntax
try
{
//Perform Action
}
catch(ExceptionType1 exp1)
{
//Catch block no 1
}
catch(ExceptionType2 exp2)
{
//Catch block no 2
}
catch(ExceptionType3 exp3)
{
//Catch block no 3
}
{
//The finally block no always executes.
}

No comments:

Post a Comment