There would be some scenarios where we need to assert that a particular emenet is not present or element is hidden on a page.

we need to do the following to assertElementNotPresent:
Create a class by Name: public class Element

Inside the class Element.java add the following method by name isHidden()
public static Boolean isHidden( WebDriver webDriver, By by )

{

try

{

WebElement element = webDriver.findElement( by );

return false;

}

catch ( NoSuchElementException e )

{

return true;

}

}

what the above does is it gets the Element not found exception and returns true.
How to implement the above class and method:

In the actual test add the following:

assertTrue( Element.isHidden( getWebDriver(),   By.xpath( xpathLocator ) ) );