コード例 #1
0
  public Field field(String field) {
    HtmlInput input = form.getInputByNameOrId(field);
    if (input != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Field is an input: " + input);
      }
      return new HtmlUnitField(this, input);
    }
    HtmlTextArea textArea = form.getTextAreaByNameOrId(field);
    if (textArea != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Field is a textarea: " + input);
      }
      return new HtmlUnitTextArea(this, textArea);
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Trying to find a generic input");
    }
    HtmlElement element = form.getElementByIdOrDie(field);
    if (element instanceof HtmlTextArea) {
      return new HtmlUnitTextArea(this, (HtmlTextArea) element);
    }
    return new HtmlUnitField(this, (HtmlInput) element);
  }