[Webtest] Newbie needs help with cookie testing

Marc Guillemot webtest@lists.canoo.com
Tue, 23 May 2006 08:26:58 -0700 (PDT)


Hi Mili,

welcome to WebTest.

Concerning your tests
- each time you run a test you will have no cookie and therefore simulate a
new user.
- to simulate a visitor that visit again within 30 days, you will need to
generate a cookie as first step of your test. There is no step doing this
currently but a small script can do the work:
<webtest>
...
<steps>
  <groovy>
def cookie = new org.apache.commons.httpclient.Cookie("your domain", "cookie
name", "cookie value")
step.context.webClient.webConnection.state.addCookie(cookie)
  </groovy>
 ...
</steps>
</webtest>

See:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/Cookie.html
for details about various cookie constructors

If you identify registered users with cookies to, then a similar setup can
be done.

Marc.
--
View this message in context: http://www.nabble.com/Newbie+needs+help+with+cookie+testing-t1664308.html#a4525120
Sent from the WebTest forum at Nabble.com.