0

I'm trying to catch an InvalidStateException (and only this exception!) but my code is throwing out an ElementNotVisibleException and it is still being caught. I know that this is the problem because I did this:

try{
    thrown new ElementNotVisibleException("why???");
}
catch(InvalidElementStateException e){
    System.out.println("Welp, this sucks.");
}

And, welp, this sucks.

Selenium javadocs doesn't list ElementNotVisibleException as a subclass of InvalidElementState Exception, yet Java seems to think that this is the case. Can anyone enlighten me/suggest a workaround? Thanks!

Oh, and I'm using Java 7, Selenium 2.46.

2
  • Ah, I now realize I was looking at outdated javadocs... Commented Jul 20, 2015 at 21:41
  • Happens to the best of us. :) Commented Jul 20, 2015 at 21:43

2 Answers 2

1

ElementNotVisibleException is a subclass of InvalidElementStateException, ElementNotVisibleException is an InvalidElementStateException. This is completely expected behavior.

Sign up to request clarification or add additional context in comments.

Comments

0

Actually Selenium javadocs do list ElementNotVisibleException as a subclass of InvalidElementState and thus as @Andrew already said, the behavior is as expected/designed. -> see here

I quote:

public class ElementNotVisibleException
extends InvalidElementStateException

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.