/** * Add an attribute to an element. * * @param attributeType - Attribute to add (e.g. class). * @param value - Value to assign to the attribute. * @param locator - XPath location of the attribute. * @throws Exception */ public void addAttribute(String attributeType, String value, String locator) throws Exception { Element element = getElement(locator); element.setAttribute(attributeType, value); }
/** * Add text to an element. * * @param text - Text to add to the element. * @param locator - XPath location of the element. * @throws Exception */ public void addTextToElement(String text, String locator) throws Exception { Element element = getElement(locator); Node textNode = xmlDocument.createTextNode(text); element.appendChild(textNode); }
/** * Add a child element to an existing element (Will go to the end of the list) * * @param elementType - Type of child element to add (e.g. div) * @param locator - XPath location of the element. * @throws Exception */ public void addChildElement(String elementType, String locator) throws Exception { Element element = getElement(locator); Node childNode = xmlDocument.createElement(elementType); element.appendChild(childNode); }