I have used C and done much work with Unix internals over 20 years, but am very
new to programing and testing with html, java, xml, XPath, ... type web
services. I am attempting to use WebTest to validate some new RESTful APIs. In
doing this I have run into what I'm sure is a very basic problem that many of
you could easily handle.
I have the following test file to do a login using a RESTful uri endpoint. I
can do the login, but I have not seen how I can verify the returned statusCode
nor how I can get the returned session ID to use as an input for other endpoint
calls I will be testing. I would simply like to know what I have to do to
verify the statusCode then get and save the session ID so I can use it later.
I'm thinking I need to perhaps use the verifyXPath with something like:
<verifyXPath
description="Get the status
code"
regex="false"
text="200"
xpath="//[EMAIL
PROTECTED]'200']"
/>
but I'm not positive as I have not gotten this to work. All suggestions would
be appreciated.
My tests/loginValidUser.xml file contains:
-----------
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd">
<project name="loginValidUser" default="test">
<target name="test">
<webtest name="Login valid User">
<steps>
<invoke
url="http://10.0.1.1:8080/identity/v1/login" username="jon" password="1234pass"
description="Login valid user"/>
<!-- I want to be able to verify the statusCode from this operation is 200
If it is then I want to be able to to get the session ID, store it in a
variable to use in other tests
Then proceed to the next step.
If the statusCode is not 200 I should just fail and stop all tests at this
point.
-->
</steps>
</webtest>
</target>
</project>
-----------
The response I receive to the file
results/001_LoginValidUser/001_response_invoke.xml when doing the invoke above
is:
-----------
<?xml version='1.0' encoding='UTF-8'?><identity
xmlns="http://10.0.1.1/identity/v1" xmlns:fsapi-v1="http://10.0.1.1/v1"
version="1.0.20071219.0" statusMessage="OK" statusCode="200"><session
id="434DF084FA5968055B802AF6F4073725" /></identity>
-----------
Again, thanks for any help you may be able to provide me to get past this
initial road block.
Doug
----------------------------------------------------------------------
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