Package com.canoo.webtest.engine

Examples of com.canoo.webtest.engine.StepFailedException


    private HtmlElement findElementByTypeAndOptionalName() {
        final List li = ((HtmlPage) getContext().getCurrentResponse()).getDocumentElement().getHtmlElementsByTagName(getType());
        LOG.debug(li.size() + " elts found of type \"" + getType() + "\"");
        if (li.isEmpty()) {
            throw new StepFailedException("No element found of type \"" + getType() + "\"", this);
        }
        if (li.size() > 1 && getName() == null) {
            throw new StepFailedException("More than 1 element with type \"" + getType()
               + "\" found! No name is specified.",
               this);
        }

        final HtmlElement elt;
        if (getName() != null) {
          final List namedElements = findNodesWithAttribute(li, ELEMENT_ATTRIBUTE_NAME, getName());

            if (namedElements.isEmpty()) {
                throw new StepFailedException("No element of type \"" + getType() + "\" and name \"" + getName()
                   + "\" found!",
                   this);
            }
            if (namedElements.size() > 1) {
                throw new StepFailedException("More than 1 element of type \"" + getType() + "\" with name \"" + getName()
                   + "\" found!",
                   this);
            }
            elt = (HtmlElement) namedElements.get(0);
        }
View Full Code Here


      final PDFLink element = (PDFLink) iter.next();
      if (verifyLink(element, verifier, expectedValue))
        return;
    }
     
      throw new StepFailedException("No link found matching criteria.");
    }
View Full Code Here

        try {
            folder = getHelper().getInboxFolder(configInfo);
            final int id = ConversionUtil.convertToInt(getMessageId(), 0);
            final Message message = getHelper().getMessage(id, folder);
            if (message == null) {
                throw new StepFailedException("Could not retrieve message.", this);
            }
            performOperation(message);
        } catch (MessagingException e) {
            throw new StepFailedException("Error performing operation: " + e.getMessage(), this);
        } finally {
            getHelper().logout(folder, fDeleteOnExit);
        }
    }
View Full Code Here

    }
    else if (e instanceof FailingHttpStatusCodeException)
    {
      LOG.debug("Wrapping FailingHttpStatusCodeException in StepFailedException: " + e.getMessage());
      final FailingHttpStatusCodeException he = (FailingHttpStatusCodeException) e;
      throw new StepFailedException("HTTP error " + he.getStatusCode(), he);
    }
    else if (e instanceof XPathException)
    {
      LOG.debug("Wrapping XPathException in StepFailedException: " + e.getMessage());
      throw new StepFailedException(e.getMessage(), (Exception) e);
    }
    else if (e instanceof ScriptException)
    {
      final ScriptException se = (ScriptException) e;
      final HtmlPage page = se.getPage(); // should normally not be null but it happens in HtmlUnit 1.14 ;-(
      final StepFailedException sfe = new StepFailedException(
          "JavaScript error loading page "
              + (page != null ? page.getWebResponse().getUrl().toString() : "")
              + ": " + se.getMessage(), se);
      sfe.addDetail("javascript error", se.getMessage());
      sfe.addDetail("line", String.valueOf(se.getFailingLineNumber()));
      sfe.addDetail("javascript source", se.getScriptSourceCode());
      sfe.addDetail("failing line", se.getFailingLine());

      // the javascript call stack
      final StringWriter stringWriter = new StringWriter();
      final PrintWriter printWriter = new PrintWriter(stringWriter);
      se.printScriptStackTrace(printWriter);
      sfe.addDetail("javascript call stack", stringWriter.toString());

      throw sfe;
    }
    else if (e instanceof SocketTimeoutException)
    {
      final SocketTimeoutException ste = (SocketTimeoutException) e;
      throw new StepFailedException("Server took to long to answer: "
          + ste.getMessage(), ste);
    }
    else if (e instanceof SAXException)
    {
      throw new StepExecutionException("Response is not well-formed: "
View Full Code Here

        final String origType = context.getCurrentResponse().getWebResponse().getContentType();
        try {
            ContextHelper.defineAsCurrentResponse(context, getTableLocator().locateText(context, this), origType,
                    "http:" + getClass().getName());
        } catch (TableNotFoundException tableNotFound) {
            throw new StepFailedException("Cannot find table: " + tableNotFound.toString(), this);
        } catch (IndexOutOfBoundsException ioobe) {
            throw new StepFailedException("Cannot find cell with supplied index in table", this);
        } catch (SAXException se) {
            throw new StepFailedException("Can't parse table: " + se.getMessage(), this);
        }
    }
View Full Code Here

  protected void setField(HtmlElement element) throws IOException {
    // useful only if element was searched by id or xpath
    String attributeValue = element.getAttribute(HtmlConstants.TYPE);
    if (!HtmlConstants.FILE.equals(attributeValue)) {
      throw new StepFailedException("HTML input with id='" + getHtmlId() + "' is of type '"
        + attributeValue + "' but should be '" + HtmlConstants.FILE + "'", this);
    }
    final HtmlFileInput fileInput = (HtmlFileInput) element;
    fileInput.setValueAttribute(getFileName().getAbsolutePath());
  }
View Full Code Here

    }

    final WebWindow frameWindow = getFrame(page, fName, fHtmlId);

    if (frameWindow == null) {
      throw new StepFailedException(getStepLabel() + " Frame not found with name: " + fName + " available: "
         + page.getFrames(),
         this);
    }
    return frameWindow.getEnclosedPage();
  }
View Full Code Here

        LOG.debug("Selecting window " + getName());
        final Context context = getContext();
        final WebClient webClient = context.getWebClient();
        final WebWindow window = findTopLevelWindow(webClient);
        if (window == null) {
          final StepFailedException sfe = new StepFailedException("No window found");
          sfe.addDetail("available windows", getAvailableWindowsMessage(webClient));
          throw sfe;
        }

        context.saveResponseAsCurrent(window.getEnclosedPage());
    }
View Full Code Here

      return null;
    }
    if (node instanceof HtmlElement) {
      return checkFoundElement((HtmlElement) node);
    }
    throw new StepFailedException("The xpath doesn't select an HTML element but a '" + node.getClass() + "'");
  }
View Full Code Here

      fields = pdfPage.getFields(getName());
    else
      fields = pdfPage.getFields(getName(), getPage());
   
    if (fields.isEmpty())
      throw new StepFailedException("No field found", this);
   
    for (final Iterator iter = fields.iterator(); iter.hasNext();) {
      final PDFField field = (PDFField) iter.next();
      if (field.isReadOnly() != getReadOnly())
      {
        final String msg = "Field with name >" + getName() + "< is " + (field.isReadOnly() ? "" : "not ")
          + "read-only!";
        throw new StepFailedException(msg, this);
      }
    }
  }
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.