Package com.canoo.webtest.engine.xpath

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


    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

    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

TOP

Related Classes of com.canoo.webtest.engine.xpath.XPathHelper

Copyright © 2018 www.massapicom. 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.