Esempio n. 1
0
  /**
   * Returns the element with the specified ID, as long as it is an HTML element; <tt>null</tt>
   * otherwise.
   *
   * @param id the ID to search for
   * @return the element with the specified ID, as long as it is an HTML element; <tt>null</tt>
   *     otherwise
   */
  public Object jsxFunction_getElementById(final String id) {
    final XmlPage xmlPage = (XmlPage) getDomNodeOrDie();
    final Object domElement = xmlPage.getFirstByXPath("//*[@id = \"" + id + "\"]");
    if (domElement == null) {
      return null;
    }

    if (domElement instanceof HtmlElement) {
      return ((HtmlElement) domElement).getScriptObject();
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("getElementById(" + id + "): no HTML DOM node found with this ID");
    }
    return null;
  }