@Component @KeywordInfo( name = "Get Element Attribute", description = "Get Element Attribute", parameters = {"element", "attributeName"}) public class GetElementAttribute extends AbstractXMLKeyword { public static final HighlightRobotLogger LOG = HighlightRobotLogger.getLogger(GetElementAttribute.class); @Override public Object execute(Object[] params) throws ParserConfigurationException, IOException, SAXException { Element element = (Element) params[0]; String attributeName = String.valueOf(params[1]); StringBuilder buf = new StringBuilder(); buf.append("<b>Element:</b>") .append(HighlighterUtils.INSTANCE.highlightXML(XMLFormatter.prettyPrint(element))); LOG.pureHtml(buf.toString()); String result = element.getAttribute(attributeName); LOG.createAppender() .appendBold("Get Element Attribute:") .appendProperty("Attribute", attributeName) .appendProperty("Result", result) .log(); return result; } }
@Override public Object execute(Object[] params) throws ParserConfigurationException, IOException, SAXException { Element element = (Element) params[0]; String attributeName = String.valueOf(params[1]); StringBuilder buf = new StringBuilder(); buf.append("<b>Element:</b>") .append(HighlighterUtils.INSTANCE.highlightXML(XMLFormatter.prettyPrint(element))); LOG.pureHtml(buf.toString()); String result = element.getAttribute(attributeName); LOG.createAppender() .appendBold("Get Element Attribute:") .appendProperty("Attribute", attributeName) .appendProperty("Result", result) .log(); return result; }