1

I'm using Apache POI for excel operation. I'm able to print what exception it is in excel by writing a print statement in that particular catch() block. But I also want the reason for that exception..like if there is elementNotFoundException....then it should show particular ID/xpath/...is not found. So, if this is possible, then how to do this ?? Thank you

1

Great, When you are able to print stack stress or particular catch block() you will get particular ID/Xpath which is not found

  • You just need to again add smartness using that print statement
  • Find all exception and accordingly you can write method as you wanted particular ID,XPATH or name
| improve this answer | |
0

You can write following thing in your catch statement

try {
...
...
// Your code
} catch (Exception | AssertionError error) {
.....
.....
// Your code
throw error;
}

Here we are catching 2 types of exceptions Exception and AssertionError that error gets stored in error variable and we are throwing the error which was caught after all your actions are performed in catch block

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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