William,
I really appreciate your responses and thoughts. I agree my thinking about
failing but continuing with more tests is NOT a correct thing to do.
I've finished my meeting so can now get back on trying your suggestions. What
I'm hoping to now accomplish with the test is that if the StatusCode is correct
I want the ifStep /condition to proceed with more testing. If the StatusCode is
incorrect I simply want the test to "show/log" a failure and not do the
conditional ifStep code.
I've believe the following does this but please feel free to comment if you see
that I am doing something wrong or could do this better. I now set the
property "test" to use both in the condition and in the verifyProperty
following the </ifStep> as I continue to get anew and reuse StatusCode within
the ifStep/condition section of the code. (Apologies for the large sample code
that follows.)
---------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "../../dtd/Project.dtd">
<project name="getMeWithValidSessionId" default="test">
<target name="test">
<webtest name="Get 'Me' With Valid SessionId">
<config>
<option name="ThrowExceptionOnFailingStatusCode" value="false"/>
</config>
<steps>
<invoke url="http://${HOST}:${PORT}/identity/${VERSION}/login"
username="${VALIDUSER}" password="${VALIDPASSWORD}"
description="Get 'Me' With Valid SessionId"
/>
<verifyXPath
description="Check login status code equals 200"
xpath="//@statusCode='200'"
/>
<storeXPath
description="Extract StatusCode"
property="StatusCode"
xpath="//@statusCode"
/>
<echo message="#{StatusCode}"/>
<storeProperty property="test" value="#{StatusCode}" eval="false"/>
<ifStep description="if StatusCode == 200 do the following:">
<condition>
<verifyProperty property="test" text="200"/>
</condition>
<storeXPath
description="Extract session ID for use with future calls"
property="sessionID"
xpath="//@id"
/>
<echo message="#{sessionID}"/>
<invoke
url="http://${HOST}:${PORT}/familytree/${VERSION}/person/me/?sessionId=#{sessionID}"
description="Get person"
/>
<verifyXPath
description="getPerson me - Check status code equals 200"
xpath="//@statusCode='200'"
/>
<storeXPath
description="Extract me ID for use with future calls"
property="meID"
xpath="//@id"
/>
<echo message="#{meID}"/>
<storeXPath
description="Extract Persons object for use with future calls"
property="personsObject"
xpath="/"
/>
<echo message="#{personsObject}"/>
<invoke
url="http://${HOST}:${PORT}/identity/${VERSION}/logout?sessionID='#{sessionID}'"
description="Logout Valid User"
/>
<verifyXPath
description="Check logout status code equals 200"
xpath="//@statusCode='200'"
/>
</ifStep>
<verifyProperty property="test" text="200"/>
</steps>
</webtest>
</target>
</project>
---------------------------------------------------------------------------
Regards,
Doug
>>> "Soula, William" <[EMAIL PROTECTED]> 02/13/08 9:44 AM >>>
The verifyProperty won't work in the ifStep but you could but it after the
ifStep. I don't know what you are trying to do because you want the test to
fail if the statusCode is not 200 but you still want to run tests? I don't
think this is correct testing structure but I could be wrong :) I have coded
the below code and it fails after the ifStep, don't know if it will help or not
:)
<config host="www.google.com" protocol="http" port="80">
<option name="ThrowExceptionOnFailingStatusCode" value="false"/>
</config>
<storeProperty property="test" value="20" eval="false"/>
<ifStep>
<condition>
<verifyProperty property="test" text="200"/>
</condition>
<invoke url=""/>
</ifStep>
<verifyProperty property="test" text="200"/>
<invoke url="/pics/loginfiles"/>
<verifyTitle text="404 Not Found"/>
William Soula
QA Analyst
Pointserve, Inc.
110 Wild Basin Road
Suite 300
Austin, Texas 78746
O: 512.617.5311
F: 512.617.0466
----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended recipient(s) and
may contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies of
the original message.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest