Package com.canoo.webtest.engine

Examples of com.canoo.webtest.engine.Context


    /**
     * looks for missing images referenced in the page
     */
    public void doExecute() {
        nullResponseCheck();
        final Context context = getContext();
        final WebClient conversation = context.getWebClient();
        final HtmlPage currentResponse = context.getCurrentHtmlResponse(this);

        context.suspendWindowListener();
        final Collection colFailedImagesSrc = checkImages(conversation, currentResponse);
        context.restoreWindowListener();

        if (!colFailedImagesSrc.isEmpty()) {
          final StepFailedException sfe = new StepFailedException(colFailedImagesSrc.size() + " missing image(s) in page "
              + currentResponse.getWebResponse().getRequestUrl());

View Full Code Here


     *
     * @throws com.canoo.webtest.engine.StepExecutionException if no form is found
     */
    public void doExecute() throws Exception {
        nullResponseCheck();
        final Context context = getContext();
        final HtmlPage currentResp = (HtmlPage) context.getCurrentResponse();
        LOG.debug("Selecting current form in response from " + currentResp.getWebResponse().getRequestUrl());
        HtmlForm form;
        if (fName != null) {
            form = FormUtil.findFormByName(currentResp, fName);
        } else {
            form = FormUtil.findFormByIndex(currentResp, fIndex);
        }
        if (form == null) {
            throw new StepFailedException("Form not found in doc", this);
        }
        context.setCurrentForm(form);
    }
View Full Code Here

      // but needs to be here to allow Ant to "set" it
    }

    public void doExecute() throws Exception {
        final List steps = getSteps();
        Context context = getContext();
        applyTableFilterIfNeeded(context);
        applyExtractionIfNeeded(context);
        if (!steps.isEmpty())
        {
            for (int i = 0; i < steps.size(); i++) {
                context = processFilterStep(context, (Step) steps.get(i));
            }
            final Page currentResponse = context.getCurrentResponse();
            ContextHelper.defineAsCurrentResponse(getContext(), currentResponse.getWebResponse().getContentAsBytes(),
                    currentResponse.getWebResponse().getContentType(), "http:" + getClass().getName());
        }
    }
View Full Code Here

      super.addTask(AntBoundary.maybeConfigure(newTask));
    }

    private Context processFilterStep(final Context origContext, final Step step) {
        step.perform();
        final Context newContext = step.getContext();
        newContext.saveResponseAsCurrent(newContext.getCurrentResponse());
        newContext.getConfig().setResultpath(getContext().getConfig().getWebTestResultDir());
        return newContext;
    }
View Full Code Here

    protected AbstractEmailFilter() {
        super(false);
    }

    protected void performOperation(final Message message) throws MessagingException {
        final Context context = getContext();
        try {
            filterContent(message);
        }
        catch (final MessagingException e) {
            throw new StepFailedException("Error performing operation: " + e.getMessage(), this);
        }
        finally {
            context.saveResponseAsCurrent(context.getCurrentResponse());
            context.getConfig().setResultpath(getContext().getConfig().getWebTestResultDir());
            context.saveResponseAsCurrent(context.getCurrentResponse());
        }
    }
View Full Code Here

        return fPropertyName;
    }

    public void doExecute() {
        final List steps = getSteps();
        final Context context = getContext();
        final WebClientContext.StoredResponses origResponses = context.getResponses();
        // TODO: just make table like a normal filter, i.e. add to list of steps to execute
        applyTableFilterIfNeeded(context);
        applyExtractionIfNeeded(context);
        for (int i = 0; i < steps.size(); i++) {
            final Task step = (Task) steps.get(i);
View Full Code Here

    final String webtestVersion = PackageBoundary.versionMessage();
    LOG.info(webtestVersion);
    getProject().setProperty("webtest.version", webtestVersion);

    assertParametersNotNull();
      final Context context = new Context(this);
      CONTEXT_HOLDER.set(context);
     
      LOG.debug("Executing configuration task");
      getConfig().setContext(context);
      getConfig().perform();

      // register custom property helper in place of the original one
      final PropertyHelper originalPropertyHelper = PropertyHelper.getPropertyHelper(getProject());
     
      WebtestPropertyHelper.configureWebtestPropertyHelper(getProject());
     
      // register the listener that will capture the results
      fResultBuilderListener = getWebtestCustomizer().createExecutionListener(this);
      getProject().addBuildListener(fResultBuilderListener);

      try {
            executeSteps();
      }
      catch (final BuildException e) {
            // nothing, exception is available in result build listener too
      }
      finally {
        fResultBuilderListener.webtestFinished();
            getProject().removeBuildListener(fResultBuilderListener);
            WebtestPropertyHelper.definePropertyHelper(getProject(), originalPropertyHelper);
           
            // clean the WebClient(s) to stop running js scripts (like setTimeout)
            for (final Iterator iter=context.getWebClientContexts().values().iterator(); iter.hasNext();)
            {
              final WebClientContext webClientContext = (WebClientContext) iter.next();
              webClientContext.destroy();
            }
      }
View Full Code Here

    try {
      verifyParameters();
      doExecute();
     
      // give time for background js tasks to finish when needed
      final Context context = getContext();
      final Page currentPage = context.getCurrentResponse();
      if (!(this instanceof IVerificationStep) && currentPage != null && context.getConfig().isEasyAjax()) {
        currentPage.getEnclosingWindow().getThreadManager().joinAll(context.getConfig().getEasyAjaxDelay());
      }
     
      final ScriptException bgException = context.getBackgroundJSError();
      if (bgException != null) {
        handleException(bgException);
      }
    }
    catch (final Exception ex) {
View Full Code Here

{
  private String fRestoredResponseUrl;

    public void doExecute() {
        nullResponseCheck();
        final Context context = getContext();
        context.restorePreviousResponse();
    fRestoredResponseUrl = context.getCurrentResponse().getWebResponse().getRequestUrl().toString();
  }
View Full Code Here

  }

  private String getDynamicPropertyValue(final String propName) {
    if (propName.startsWith("script:"))
    {
        final Context context = WebtestTask.getThreadContext();
          if (context == null || context.getRunner() == null) {
              return null;
          }
      final String expr = StringUtils.substringAfter(propName, "script:");
      return ScriptStep.evalScriptExpression(context, expr, null);
    }
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.