[Webtest] ScriptStep and JavaScript: flow control and APIs for imported objects
Mike B
Mike B <mikebigg@yahoo.com>
Thu, 13 Dec 2007 05:58:54 -0800 (PST)
--0-160438557-1197554334=:35936
Content-Type: text/plain; charset=us-ascii
Greetings.
I am attempting to use the <ScriptStep> with JavaScript to create some conditional branches (i.e. flow controls) for WebTest testing scripts. I am having problems locating the best way to accomplish this.
MY QUESTIONS
How do you implement conditional branching using a scripting solution in WebTest
<IFStep> isn't flexible enough for my needs.Where do I find detailed information about the <ScriptStep> objects?This link describes the step but not the APIs for the objects it imports.
More details on my questions below.
Here is what I mean by flow control or conditional branching:
FLOW CONTROL (THE BASICS)
execute step#1
execute step#2
if ( ${user} == "name1" ) then
execute step#3
else ( if ${user} == "name2" ) then
execute step#4
end if
PREFERRED SOLUTIONS
Note: it appears there used to be an <IF> statement but it appears to be missing from the current distribution (at least as of R_1632). That'd probably do what I need if it were working.
I'd like to use on of these two forms for flow control (both is possible):
FORM 1
Use <ENTITY..> to include include xml fragments from other files
Those xml fragments would use an if/then/else logic to execute other steps (verifyText, verifyTitle, etc.)
FORM 2
use <ScriptStep>and execute specific instructions within the <ScriptStep>,based some conditions (ie. if ( username =="..", etc)
I have not found a way to create a VerifyText step object in JavaScript inside a <ScriptStep>. Also, I haven't been able to determine how I can call a verifyText(..) method (for example) inside the script.
Can anyone give me some hints for how to use JavaScript inside a <ScriptStep> to perform conditional testing to alter the flow of a testing script?
RANGE OF ACTIONS
While I know JavaScript, I do not know what the all the available objects and behaviors are. The documentation shows access to objects step, document and response and at least one website showed the project and ant objects were available inside a <ScriptStep> too.
However, while the document object is fairly well document as a JavaScript object, I do not find a list of methods for step, response, project or ant objects. Are there any global methods imported into the scripting context too? Where can I find this information?
Mike
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
--0-160438557-1197554334=:35936
Content-Type: text/html; charset=us-ascii
<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>Greetings.<br><br>I am attempting to use the <span style="font-weight: bold;"><ScriptStep></span> with JavaScript to create some conditional branches (i.e. flow controls) for WebTest testing scripts. I am having problems locating the best way to accomplish this.<br><br><span style="font-weight: bold;">MY QUESTIONS</span><br><ol><li>How do you implement conditional branching using a scripting solution in WebTest <br></li><ol><li><span style="font-weight: bold;"><IFStep></span> isn't flexible enough for my needs.</li></ol><li>Where do I find detailed information about the <span style="font-weight: bold;"><ScriptStep></span> objects?</li><ol><li>This <a href="http://webtest.canoo.com/webtest/manual/scriptStep.html">link </a>describes the step but not the APIs for the objects
it imports.<br></li></ol></ol><br>More details on my questions below.<br><br>Here is what I mean by flow control or conditional branching:<br><br><span style="font-weight: bold;">FLOW CONTROL (THE BASICS)</span><br><div style="margin-left: 40px;"><span style="font-family: courier,monaco,monospace,sans-serif;"><br>execute step#1</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">execute </span><span style="font-family: courier,monaco,monospace,sans-serif;">step#2</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">if ( ${user} == "name1" ) then</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;"> </span><span style="font-family: courier,monaco,monospace,sans-serif;">execute </span><span style="font-family:
courier,monaco,monospace,sans-serif;">step#3</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;">else ( if </span><span style="font-family: courier,monaco,monospace,sans-serif;">${user}</span><span style="font-family: courier,monaco,monospace,sans-serif;"> == "name2" ) then</span><br style="font-family: courier,monaco,monospace,sans-serif;"><span style="font-family: courier,monaco,monospace,sans-serif;"> </span><span style="font-family: courier,monaco,monospace,sans-serif;">execute </span><span style="font-family: courier,monaco,monospace,sans-serif;">step#4<br>end if<br></span></div><br><span style="font-weight: bold;">PREFERRED SOLUTIONS</span><br><br>Note: it appears there used to be an <span style="font-weight: bold;"><IF></span> statement but it appears to be missing from the current distribution (at least as of R_1632). That'd probably do what I need
if it were working.<br><br>I'd like to use on of these two forms for flow control (both is possible):<br><br><span style="font-weight: bold;">FORM 1</span><br><ul><li>Use <span style="font-weight: bold;"><ENTITY..></span> to include include xml fragments from other files<br></li><li>Those xml fragments would use an if/then/else logic to execute other steps (<span style="font-weight: bold;">verifyText</span>, <span style="font-weight: bold;">verifyTitle</span>, etc.)</li></ul><br><span style="font-weight: bold;">FORM 2</span><br><ul><li>use <span style="font-weight: bold;"><ScriptStep></span>and execute specific instructions within the <span style="font-weight: bold;"><ScriptStep></span>,based some conditions (ie. <span style="font-style: italic;">if ( username ==".."</span>, etc)</li></ul><br>I have not found a way to create a <span style="font-weight: bold;">VerifyText </span>step object in JavaScript inside a <span
style="font-weight: bold;"><ScriptStep></span>. Also, I haven't been able to determine how I can call a <span style="font-weight: bold;">verifyText(..)</span> method (for example) inside the script.<br><br>Can anyone give me some hints for how to use JavaScript inside a <span style="font-weight: bold;"><ScriptStep></span> to perform conditional testing to alter the flow of a testing script?<br><br><span style="font-weight: bold;">RANGE OF ACTIONS</span><br><br>While I know JavaScript, I do not know what the all the available objects and behaviors are. The documentation shows access to objects <span style="font-weight: bold;">step</span>, <span style="font-weight: bold;">document </span>and <span style="font-weight: bold;">response </span>and at least one website showed the <span style="font-weight: bold;">project </span>and <span style="font-weight: bold;">ant </span>objects were available inside a <span style="font-weight:
bold;"><ScriptStep></span> too.<br><br>However, while the <span style="font-weight: bold;">document</span> object is fairly well document as a JavaScript object, I do not find a list of methods for <span style="font-weight: bold;">step</span>, <span style="font-weight: bold;">response</span>, <span style="font-weight: bold;">project </span>or <span style="font-weight: bold;">ant </span>objects. Are there any global methods imported into the scripting context too? Where can I find this information?<br><br>Mike<br><br><br><br></div></div><br>
<hr size=1>Never miss a thing. <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>
</body></html>
--0-160438557-1197554334=:35936--