Package com.canoo.webtest.engine

Examples of com.canoo.webtest.engine.StepFailedException


        final String result = getProject().replaceProperties(s);
        try {
            return Double.parseDouble(result);
        }
        catch (final NumberFormatException e) {
            throw new StepFailedException("Attempted to evaluate non-numeric property '"
                    + s + "': " + e.getMessage(), this);
        }
    }
View Full Code Here


        final String text = getContext().getCurrentResponse().getWebResponse().getContentAsString(); // possible IOException

        // "." should match new lines as well, therefore the dotall flag
        final Matcher matcher = Pattern.compile(getText(), Pattern.DOTALL).matcher(text);
        if (!matcher.find()) {
            throw new StepFailedException("No match for regular expression <" + getText() + ">", this);
        }

        final int numberOfGroups = matcher.groupCount();

        int groupNumber = ConversionUtil.convertToInt(fGroup, 0);
        if (groupNumber > numberOfGroups) {
            throw new StepFailedException("Group not found: " + fGroup + " (#groups: " + numberOfGroups + ")", this);
        }

        storeProperty(matcher.group(groupNumber));
    }
View Full Code Here

        return fResponse;
    }

    public void verify(final String actual) {
        if (getText() != null && !super.verifyText(actual)) {
            throw new StepFailedException("Wrong dialog message found! [Regex=" + isRegex() + "]",
                getText(), actual, this);
        }
    }
View Full Code Here

    if (result == null
      || (result.length() == 0 && xpathHelper.selectFirst(currentResponse, getXpath()) == null)) {

      if (getDefault() == null)
      {
        throw new StepFailedException("No match for xpath expression <" + fXpath + ">", this);
      }
      else
      {
        LOG.debug("No result, using default value");
        return getDefault();
View Full Code Here

      final PDFBookmark element = (PDFBookmark) iter.next();
      if (verifier.verifyStrings(getName(), element.getTitle()))
        return; // bookmark found
    }
     
      throw new StepFailedException("No bookmark found with name >" + getName() + "< (regex: " + getRegex() + ")", this);
    }
View Full Code Here

        }
        if (content instanceof Multipart) {
            final Multipart mp = (Multipart) content;
            final int part = ConversionUtil.convertToInt(getPartIndex(), 0);
            if (part >= mp.getCount()) {
                throw new StepFailedException("PartIndex too large.", this);
            }
            return arrayToString(mp.getBodyPart(part).getHeader(getHeaderName()));
        }
        throw new StepFailedException("PartIndex supplied for a non-MultiPart message.", this);
    }
View Full Code Here

   *
   * @see com.canoo.webtest.steps.Step#doExecute()
   */
  public void doExecute() {
    if (!getWebtestProperties(getPropertyType()).containsKey(getName())) {
      throw new StepFailedException("Expected property \"" + getName() + "\" to be defined!",
         this);
    }
    final String propValue = getWebtestProperty(getName(), getPropertyType());
    LOG.debug("propName=" + getName() + ", propertyType=" + getPropertyType() + ", value=" + propValue
       + ", text=" + getText());

    // null text indicates we are just checking if property is defined
    if (getText() != null && !verifyText(propValue)) {
      throw new StepFailedException("Incorrect property value found!", getText(), propValue,
         this);
    }
  }
View Full Code Here

        msg += fields.size();
      msg += " field(s) found with name >" + getName() + "<";
      if (getPage() != ANY_PAGE)
        msg += " on page " + getPage();
     
      final StepFailedException sfe = new StepFailedException(msg);
      final List availableFiels;
      if (getPage() == ANY_PAGE)
        availableFiels = pdfPage.getFields();
      else
        availableFiels = pdfPage.getFields(getPage());

      if (availableFiels.isEmpty())
        sfe.addDetail("available fields", "- none -");
      else
      {
        final StringBuffer sb = new StringBuffer();
        for (final Iterator iter=availableFiels.iterator(); iter.hasNext();)
        {
          final PDFField field = (PDFField) iter.next();
          sb.append(field.getName());
          sb.append("\n");
        }
        sfe.addDetail("available fields", sb.toString());
      }
      throw sfe;
    }
  }
View Full Code Here

            // but what about an assert in groovy's implementation that has failed - this should
            // probably be configurable to potentially throw StepExecutionError
        } catch (AssertionError ae) {
            final String msg = "Assertion error during scriptStep: " + ae.getMessage();
            LOG.debug(msg, ae);
            throw new StepFailedException(msg, this);
        } catch (BuildException be) {
            LOG.debug(be.getMessage(), be);
            throw new StepExecutionException("Error invoking script: " + be.getMessage(), this);
    } finally {
            if (!isKeep()) {
View Full Code Here

      LOG.error("CompilationFailedException", e);
      throw new StepExecutionException("Cannot compile groovy code: " + script, step, e);
    }
        catch (final AssertionError e) {
            LOG.info("AssertionError", e);
            throw new StepFailedException("Assertion failed within groovy code: " + script, step);
        }
        catch (final RuntimeException e)
    {
      LOG.error("RuntimeException", e);
            throw new StepExecutionException("Error invoking groovy: " + e.getMessage(), step, e);
View Full Code Here

TOP

Related Classes of com.canoo.webtest.engine.StepFailedException

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.