@Override public void clear() { assertElementNotStale(); if (element instanceof HtmlInput) { HtmlInput htmlInput = (HtmlInput) element; if (htmlInput.isReadOnly()) { throw new InvalidElementStateException("You may only edit editable elements"); } if (htmlInput.isDisabled()) { throw new InvalidElementStateException("You may only interact with enabled elements"); } htmlInput.setValueAttribute(""); } else if (element instanceof HtmlTextArea) { HtmlTextArea htmlTextArea = (HtmlTextArea) element; if (htmlTextArea.isReadOnly()) { throw new InvalidElementStateException("You may only edit editable elements"); } if (htmlTextArea.isDisabled()) { throw new InvalidElementStateException("You may only interact with enabled elements"); } htmlTextArea.setText(""); } else if (!element.getAttribute("contenteditable").equals(DomElement.ATTRIBUTE_NOT_DEFINED)) { element.setTextContent(""); } }