Examples of XPathHelper


Examples of com.canoo.webtest.engine.xpath.XPathHelper

  }

  protected void doExecuteWithXPath() throws XPathException
  {
    LOG.debug("repeat with xpath " + getXpath());
    final XPathHelper xpathHelper = getContext().getXPathHelper();
    final List nodes = getNodesByXPath();

    final int nbNodes = nodes.size();
    LOG.debug("Iterating over " + nbNodes + " nodes");
    for (final ListIterator iter = nodes.listIterator(); iter.hasNext();)
    {
      final Object node = iter.next();
      final String loopLabel = iter.nextIndex() + "/" + nbNodes;
      LOG.debug("Iteration " + loopLabel + ": placing current node >"
          + node + "< as >" + getCounterName() + "< in variable context");
      xpathHelper.getVariableContext().setVariableValue(new QName(getCounterName()), node);

      executeContainedTasks(loopLabel);
    }
  }
View Full Code Here

Examples of com.canoo.webtest.engine.xpath.XPathHelper

    return getText() != null;
  }

  protected void verifyXPath() throws XPathException, StepFailedException {
    final Page currentResponse = getContext().getCurrentResponse();
    final XPathHelper xpathHelper = getContext().getXPathHelper();

    if (isComparingPathAndValue()) {
      final String actualValue = xpathHelper.stringValueOf(currentResponse, getXpath());
      if (!verifyText(actualValue)) {
        throw new StepFailedException("Wrong result for xpath >" + fXpath + "<", getText(), actualValue, this);
      }
    }
    else
    {
      final Object singleNode = xpathHelper.selectFirst(currentResponse, getXpath());
      if (singleNode == null) {
        throw new StepFailedException("xpath test: " + fXpath + " matched no nodes", this);
      }
      else if (Boolean.FALSE.equals(singleNode))
      {
View Full Code Here

Examples of com.canoo.webtest.engine.xpath.XPathHelper

    storeProperty(evaluateXPath());
  }

  protected String evaluateXPath() throws XPathException {
    final Page currentResponse = getContext().getCurrentResponse();
    final XPathHelper xpathHelper = getContext().getXPathHelper();
    final String result = xpathHelper.stringValueOf(currentResponse, getXpath());

    // seems that result is "" and not null when nothing is found
    if (result == null
      || (result.length() == 0 && xpathHelper.selectFirst(currentResponse, getXpath()) == null)) {

      if (getDefault() == null)
      {
        throw new StepFailedException("No match for xpath expression <" + fXpath + ">", this);
      }
View Full Code Here

Examples of fiftyfive.util.XPathHelper

     */
    private static int matchCount(WicketTester tester, String xPathExpr)
            throws IOException, SAXException, ParserConfigurationException, TransformerException,
                   XPathExpressionException
    {
        NodeList nl = new XPathHelper(markupAsDOM(tester)).findNodes(xPathExpr);
        return nl != null ? nl.getLength() : 0;
    }
View Full Code Here

Examples of org.javalite.test.XPathHelper

        a.add(Tag.create("content", "orm"));
        LazyList<Article> articles = Article.where("title = ?", "ActiveJDBC polymorphic associations")
                .include(Tag.class, Comment.class);

        String xml = articles.toXml(true, true);
        XPathHelper h = new XPathHelper(xml);
        a(h.count("/articles/article")).shouldEqual(1);
        a(h.count("/articles/article/comments/comment")).shouldEqual(1);
        a(h.count("/articles/article/tags/tag")).shouldEqual(1);
        the(h.selectText("/articles/article[1]/comments/comment[1]/content")).shouldBeEqual(
                "this is just a test comment text");
        the(h.selectText("/articles/article[1]/tags/tag[1]/content")).shouldBeEqual("orm");
    }
View Full Code Here

Examples of org.javalite.test.XPathHelper

        checkXmlStructure(u.toXml(true, true));
        checkXmlStructure(u.toXml(false, true));
    }

    private void checkXmlStructure(String xml){
        XPathHelper h = new XPathHelper(xml);
        the(h.selectText("//first_name")).shouldBeEqual("Marilyn");
        the(h.selectText("//last_name")).shouldBeEqual("Monroe");
        the(h.count("//address")).shouldBeEqual(4);
        the(h.selectText("//address[1]/address1")).shouldBeEqual("123 Pine St.");
        the(h.selectText("//address[2]/address1")).shouldBeEqual("456 Brook St.");
        the(h.selectText("//address[3]/address1")).shouldBeEqual("23 Grove St.");
        the(h.selectText("//address[4]/address1")).shouldBeEqual("123 Pine & Needles");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.