2

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 ?

2 Answers 2

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
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

Your Answer

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

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