[Webtest] New user - basic verification and variable
setting problem
Douglas Beattie
Douglas Beattie" <beattiedb@ldschurch.org
Fri, 11 Jan 2008 09:00:02 -0700
I'll followup my own post with some changes I've made, but which still do n=
ot work.
What am I doing wrong?
The new test .xml file I've generated and tested is as follows:
---------------
<?xml version=3D"1.0"?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd">
<project name=3D"loginValidUser" default=3D"test">
<target name=3D"test">
<webtest name=3D"Login valid User">
<steps>
<invoke url=3D"http://10.0.1.1:8080=
/identity/v1/login" username=3D"jon" password=3D"1234pass"
description=3D"Login valid =
user"
/>
<verifyXPath
description=3D"Check status=
code eauals 200"
xpath=3D"//identity[@status=
Code=3D'200']"
/>
<storeXPath
description=3D"Extract sess=
ion ID for use with future calls"
xpath=3D"//identity/session=
[@id]"
property=3D"sessionID"
/>
<invoke url=3D"http://10.0.1.1:8080=
/infoList/v1/getFullList"
description=3D"Get Entire L=
ist"
/>
<invoke url=3D"http://10.0.1.1:8080=
/identity/v1/logout" sessionid=3D"#{sessionID}"
description=3D"Logout valid=
user"
/>
</steps>
</webtest>
</target>
</project>
---------------
=20
The first invoke returns:
---------------
<?xml version=3D'1.0' encoding=3D'UTF-8'?><identity xmlns=3D"http://10.0.1.=
1/identity/v1" xmlns:fsapi-v1=3D"http://10.0.1.1/v1" version=3D"1.0.2007121=
9.0" statusMessage=3D"OK" statusCode=3D"200"><session id=3D"6945B0AD3083631=
B9B9D2DAED1B5C250" /></identity>
---------------
I fail to verify the statusCode.
If I comment out the verify statusCode check then I fail to get and store t=
he sessionID to be used for logout.
Can anyone tell me the error(s) in my code?
Thanks,
Doug
>>> "Douglas Beattie" <beattiedb@ldschurch.org> 01/10/08 10:09 AM >>>=20
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 we=
b services. I am attempting to use WebTest to validate some new RESTful API=
s. 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 statu=
sCode nor how I can get the returned session ID to use as an input for othe=
r 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 u=
se it later. I'm thinking I need to perhaps use the verifyXPath with someth=
ing like:
<verifyXPath
description=3D"Get the stat=
us code"
regex=3D"false"
text=3D"200"
xpath=3D"//identity[@status=
Code=3D'200']"
/>
but I'm not positive as I have not gotten this to work. All suggestions wou=
ld be appreciated.
My tests/loginValidUser.xml file contains:
-----------
<?xml version=3D"1.0"?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd">
<project name=3D"loginValidUser" default=3D"test">
<target name=3D"test">
<webtest name=3D"Login valid User">
<steps>
<invoke url=3D"http://10.0.1.1:8080/identit=
y/v1/login" username=3D"jon" password=3D"1234pass"
description=3D"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=3D'1.0' encoding=3D'UTF- 8'?><identity xmlns=3D"http://10.0.1=
.1/identity/v1" xmlns:fsapi- v1=3D"http://10.0.1.1/v1" version=3D"1.0.20071=
219.0" statusMessage=3D"OK" statusCode=3D"200"><session id=3D"434DF084FA596=
8055B802AF6F4073725" /></identity>
-----------
Again, thanks for any help you may be able to provide me to get past this i=
nitial 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 i=
ntended recipient, please contact the sender by reply email and destroy all=
copies of the original message.
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest
----------------------------------------------------------------------
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 i=
ntended recipient, please contact the sender by reply email and destroy all=
copies of the original message.