Middle
Into which main subclasses is the Throwable class divided in Java? Which of them throws Selenide when a check fails (e.g., element.shouldBe(visible))?
sobes.tech AI
Answer from AI
In Java, the class Throwable is divided into two main subclasses:
Error— errors that are usually not handled by the application (e.g.,OutOfMemoryError).Exception— exceptions that can and should be handled.
Exception is further divided into:
- Checked exceptions, which need to be explicitly handled or declared.
- Unchecked exceptions, descendants of
RuntimeException.
In Selenide, when a check fails (for example, element.shouldBe(visible)), an unchecked exception is thrown, usually ElementNotFound or UIAssertionError, which inherit from RuntimeException. This allows the user not to be forced to explicitly handle these exceptions, but still signals a problem in the test.