[Webtest] Sleep Task?

Richard Hill webtest@lists.canoo.com
Thu, 25 Sep 2003 15:12:38 -0700


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C383B2.217E66BE
Content-Type: text/plain;
	charset="iso-8859-1"

Matt,
I'm running an older version of canoo and attached is the sleep step that I
use. 

Remember to add the step to the TestStepSequence.java

    public void addSleep(Sleep step) {
        step.setStepType("sleep");
        addStep(step);
    }

Step usage:

    <sleep
        stepid="Waiting for something to complete"
        seconds="5"/>

- Richard

-----Original Message-----
From: Matt Raible [mailto:matt@raibledesigns.com]
Sent: Thursday, September 25, 2003 12:41 PM
To: webtest@gate.canoo.com
Subject: [Webtest] Sleep Task?


Any chance that the sleep task has been added:

http://lists.canoo.com/pipermail/webtest/2003q2/000766.html

I could really use something like this in my current project (or a
workaround).  The reason is b/c we have a splash page that says "searching"
and keeps re-submitting itself with JavaScript - I need to pause and wait
for
this page to go to the next page - and then verify it's title.

Thanks,

Matt
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest


------_=_NextPart_000_01C383B2.217E66BE
Content-Type: application/octet-stream;
	name="Sleep.java"
Content-Disposition: attachment;
	filename="Sleep.java"

package com.canoo.webtest.steps;

import com.canoo.webtest.engine.TestContext;
import com.canoo.webtest.engine.TestStepFailedError;
import com.canoo.webtest.engine.TestStepSetupError;

import java.util.*;

/**
 * Sleeps for a period of time in seconds.
 *
 * Sleep Class
 * @author Richard Hill
 * @version 1.0
 */
public class Sleep extends AbstractTestStepSpecification {

    private String seconds;

    protected void doExecute(TestContext context) throws Exception {

 	expandProperties();
	verifyParameters();
	doSleep();

    }

    private void doSleep() {

	long sleepTime = (long) new Integer(seconds).intValue();

	try {
	    Thread.sleep(sleepTime * 1000);	
	} catch (InterruptedException ie) {
	}
		
    }

    private void verifyParameters() {

	try{
	    new Integer(seconds);
	}catch(NumberFormatException nfe) {
	    throw new TestStepSetupError("seconds must be an integer...check your value!", this);
	}

    }

    protected void expandProperties() {
        seconds = expandDynamicProperties(seconds);
    }

    public String getSeconds() {
        return seconds;
    }

    public HashMap getParameterDictionary() {
        HashMap map = super.getParameterDictionary();
        map.put("seconds", seconds);

        return map;
    }

    public void setSeconds(String seconds) {
        this.seconds = seconds;
    }

}

------_=_NextPart_000_01C383B2.217E66BE--