private String textOfElementWithClass(Element[] elements, String clazz) {
   for (Element div : elements) {
     if (clazz.equals(div.getAttributeValue("class"))) {
       return div.getText();
     }
   }
   return "";
 }
 public boolean hasEmbeddedCSS(String css) {
   Element head = getHeadElement();
   for (Element style : head.getChildElements("style")) {
     if (style.getText().contains(css)) {
       return true;
     }
   }
   return false;
 }
  public String getElementXML(String className) {
    Element[] childDivs = getRootElement().getDescendantElements("div");

    for (Element div : childDivs) {
      if (className.equals(div.getAttributeValue("class"))) {
        return div.toXML();
      }
    }
    return "";
  }
 public boolean hasEmbeddedJavaScript(String javaScript) {
   Element head = getHeadElement();
   for (Element script : head.getChildElements("script")) {
     String type = script.getAttributeValue("type");
     if ("text/javascript".equals(type) && script.getText().contains(javaScript)) {
       return true;
     }
   }
   return false;
 }
 public boolean hasJavaScriptDeclaration(String cssFilename) {
   Element head = getHeadElement();
   for (Element script : head.getChildElements("script")) {
     String type = script.getAttributeValue("type");
     String src = script.getAttributeValue("src");
     if ("text/javascript".equals(type) && cssFilename.equals(src)) {
       return true;
     }
   }
   return false;
 }
 public boolean hasCSSDeclaration(String cssFilename) {
   Element head = getHeadElement();
   for (Element link : head.getChildElements("link")) {
     String href = link.getAttributeValue("href");
     String type = link.getAttributeValue("type");
     String rel = link.getAttributeValue("rel");
     if (cssFilename.equals(href) && "text/css".equals(type) && "stylesheet".equals(rel)) {
       return true;
     }
   }
   return false;
 }
示例#7
0
  @Override
  public void verify(CommandCall commandCall, Evaluator evaluator, ResultRecorder resultRecorder) {
    Check.isFalse(
        commandCall.hasChildCommands(), "Nesting commands inside an 'echo' is not supported");

    Object result = evaluator.evaluate(commandCall.getExpression());

    Element element = commandCall.getElement();
    if (result != null) {
      element.appendText(result.toString());
    } else {
      Element child = new Element("em");
      child.appendText("null");
      element.appendChild(child);
    }
  }