private boolean isElementPresentJavaXPath ( ) throws Exception { String xpath = ( ( StringLocatorAwareBy ) getByLocator ( ) ) . getLocator ( ) ; try { xpath = formatXPathForJavaXPath ( xpath ) ; NodeList nodes = getNodeListUsingJavaXPath ( xpath ) ; if ( nodes . getLength ( ) > 0 ) { return true ; } else { return false ; } } catch ( Exception e ) { throw new Exception ( "Error performing isElement present using Java XPath: " + xpath , e ) ; } }
Use the Java Xpath API to determine if the element is present or not