try {
String xpathEventable = eventable.getIdentification().getValue();
Node nodeSameXpath = DomUtils.getElementByXpath(dom, xpathEventable);
if (nodeSameXpath != null) {
Element elementSameXpath = new Element(nodeSameXpath);
if (logging) {
LOGGER.info("Try element with same xpath expression");
}
if (equivalent(elementSameXpath, logging)) {
return xpathEventable;
}
}
if (logging) {
LOGGER.info("Search other candidate elements");
}
NodeList candidateElements =
XPathHelper.evaluateXpathExpression(dom, "//"
+ eventable.getElement().getTag().toUpperCase());
if (logging) {
LOGGER.info("Candidates: " + candidateElements.getLength());
}
for (int i = 0; i < candidateElements.getLength(); i++) {
Element candidateElement = new Element(candidateElements.item(i));
if (equivalent(candidateElement, logging)) {
return XPathHelper.getXPathExpression(candidateElements.item(i));
}
}