Skip to main content

Posts

Showing posts from July, 2017

Do you check for absence of element on page

When writing automated tests we often check presence or absence of element for assertion conditions. This is usually written as -  assertTrue("Element is missing. Bug!!!", pageObject. isSomeElementDisplayed()); And when element is not displayed then above mentioned assert statement fails. In the similar manner we can write following assert statement to check for absence of element -  assertFalse("Element is present. Bug!!!", pageObject. isSomeElementDisplayed()); Above mentioned assert statement would fail if element is displayed on page. Everything looks ok, is not it. Not really, there is catch. Let's have a closer look at assertFalse statement we used above -  assertFalse("Element is present. Bug!!!", pageObject. isSomeElementDisplayed()); This assert statement would also succeed even if webpage results in 404/500 or any other error page, since error page would also be missing the element on which we are p