Package com.canoo.webtest.engine

Examples of com.canoo.webtest.engine.Context


    }
    return null;
  }

  public void doExecute() throws Exception {
        final Context context = getContext();
        context.saveResponseAsCurrent(findTarget(context));
  }
View Full Code Here


    }
   

    public void doExecute() throws Exception {
        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

    protected boolean isExpectedStringPresent(final Context context) throws SAXException, IOException {
        return isExpectedStringPresent();
    }

  protected boolean isExpectedStringPresent() throws SAXException, IOException {
        Context context = getContext();
        try {
      String text;

      if (getTableLocator() == null) {
        text = context.getCurrentResponse().getWebResponse().getContentAsString();
      } else {
        text = getTableLocator().locateText(context, this);
      }
      if (isRegex()) {
        return verifyText(text);
View Full Code Here

  public String getAccept() {
    return fAccept;
  }

  public void doExecute() throws Exception {
    final Context context = getContext();
    final HtmlPage currentResponse;
    try {
      currentResponse = (HtmlPage) context.getCurrentResponse();
    } catch (ClassCastException cce) {
      throw new StepFailedException("Current response is not an html page but " + context.getCurrentResponse().getClass(), this);
    }

    final StringBuffer sb = verifyLinksOnPage(currentResponse);

    if (sb.length() > 0) {
View Full Code Here

   *
   * @throws Exception if a problem occurred
   */
  public void doExecute() throws Exception {
        final ResetScriptRunner runner; // delegate pattern
        final Context context = getContext();
        if (context.getRunner() == null) {
            runner = new ResetScriptRunner();
            runner.setLanguage(getLanguage());
            context.setRunner(runner);
            LOG.debug("Creating new Script Runner with language: " + fLanguage);
        }
        else {
            runner = context.getRunner();
            runner.reset();
        }
    buildScript();
    getProject().addReference("step", this);
    if (context.getCurrentResponse() == null) {
      LOG.warn("No response found. Previous invoke missing? Related scripting variables not created");
    }
    else {
      setupResponseScriptingVariables(context);
    }

    try {
      executeByRunner(runner, getProject().replaceProperties(fScriptText), this, getProject());
            // languages like groovy can throw assert errors which are useful to fail test
            // 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()) {
                context.setRunner(null);
            }
        }
  }
View Full Code Here

    protected int getNumberOfHits(final Context context) {
        return getNumberOfHits();
    }

    protected int getNumberOfHits() {
        Context context = getContext();
        int numberOfHits = findElementAttributeValue(context, getType(), ELEMENT_ATTRIBUTE_NAME, getText());

        if (numberOfHits == 0) {
            numberOfHits = findElementAttributeValue(context, getType(), ELEMENT_ATTRIBUTE_ID, getText());
        }
View Full Code Here

        }
    }

    private String diffContentWithExpected() throws IOException {
        final List steps = getSteps();
        final Context context = getContext();
        applyTableFilterIfNeeded(context);
        applyExtractionIfNeeded(context);

        for (final Iterator iter = steps.iterator(); iter.hasNext();) {
            final Step step = (Step) iter.next();
            executeContainedStep(step);
    }
        final WebClientContext.StoredResponses srcResponses = context.getResponses();
        final Page actualPage = context.getCurrentResponse();
        final WebResponse actualResponse = actualPage.getWebResponse();

        LOG.debug("Processig reference file: " + getReferenceFile());
      WebClientContext.StoredResponses referenceResponses = preProcessFiles(getReferenceFile(), context);
      if (isReadFiltered()) {
            LOG.debug("Applying filter on reference file too");
            context.restoreResponses(referenceResponses);
            for (final Iterator iter = steps.iterator(); iter.hasNext();) {
                final Step step = (Step) iter.next();
                step.execute();
        }
            referenceResponses = context.getResponses();
          context.restoreResponses(srcResponses);
      }

        LOG.debug("Source: " + actualResponse.getContentType() + " (" + actualResponse.getRequestUrl() + ")");
        context.restoreResponses(referenceResponses);
        final Page referencePage = context.getCurrentResponse();
        final WebResponse referenceResponse = referencePage.getWebResponse();
        LOG.debug("Reference: " + referenceResponse.getContentType() + " (" + referenceResponse.getRequestUrl() + ")");

        return produceDiffMessage(actualPage, referencePage);
    }
View Full Code Here

    }

    public void doExecute() throws SAXException, MalformedURLException {
        verifyProperties();
        nullResponseCheck();
        final Context context = getContext();
        final HtmlPage htmlPage = context.getCurrentHtmlResponse(this);
        LOG.info("Examining page with title=" + htmlPage.getTitleText());
        if (!StringUtils.isEmpty(getIncludes())) {
            LOG.info("Only including links which match '" + getIncludes() + "'");
        }
        if (!StringUtils.isEmpty(getExcludes())) {
            LOG.info("Excluding links which match '" + getExcludes() + "'");
        }
        fBaseHost = htmlPage.getWebResponse().getRequestUrl().getHost();
        final WebClient client = context.getWebClient();
        checkVisits(client, htmlPage);
        if (!fFailedVisits.isEmpty()) {
            throw new StepFailedException(fFailedVisits.size() + " broken link(s): " + brokenLinksToString(), this);
        }
    }
View Full Code Here

* The content of the last previously opened window will become the current response."
*/
public class CloseWindow extends Step {

    public void doExecute() throws Exception {
        final Context context = getContext();
       
        final TopLevelWindow window = (TopLevelWindow) context.getCurrentResponse().getEnclosingWindow().getTopWindow();
        window.close();
    }
View Full Code Here

public class ExpectDialogs extends AbstractStepContainer
{
    private static final Logger LOG = Logger.getLogger(ExpectDialogs.class);

    public void doExecute() {
        final Context context = getContext();
        DialogHelper.clearExpectedDialogs(context);
        final WebClient wc = context.getWebClient();

        for (final Iterator iter = getSteps().iterator(); iter.hasNext();) {
          final Step step = (Step) iter.next();
            DialogHelper.addExpectedDialog(context, (AbstractDialogStep) step);
            executeContainedStep(step);
View Full Code Here

TOP

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

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.