Testing / Selenium Interview questions
What are assertions in Selenium?
Selenium itself has no built-in assertion library - it only provides ways to read state from the page (getText(), isDisplayed(), getAttribute()), so assertions come from whatever test framework Selenium is paired with, like JUnit, TestNG, or AssertJ.
Assert.assertEquals(driver.getTitle(), "Dashboard"); Assert.assertTrue(driver.findElement(By.id("banner")).isDisplayed());
TestNG additionally distinguishes hard assertions, which stop the test immediately on failure, from SoftAssert, which records failures but lets the test method continue, requiring an explicit assertAll() call at the end to actually surface any recorded failures.
More Related questions...