[Webtest] Change Cookie Policy with a Groovy step

Marc Guillemot webtest@lists.canoo.com
Wed, 19 Apr 2006 07:24:24 -0700 (PDT)


Hi,

I've answered many times to questions regarding the cookie policy for users
having probems by proposing a Groovy snippet according to my understanding
of commons-httpclient's javadoc. Nobody complained therefore I was quite
sure that the code was correct even if I hadn't used it by myself. Today I
want to run a test with deactivated cookies using the code example I've
already posted... and it has no effect!

After some investigations I still don't understand the 2 logics that are
presented in the Javadoc but now have a working snippet to change the cookie
policy (here to toggle them off):

<groovy description="Change cookie policy to: ignore cookies">
  import org.apache.commons.httpclient.cookie.CookiePolicy
  import org.apache.commons.httpclient.params.*

  ((HttpClientParams)
DefaultHttpParams.getDefaultParams()).setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
</groovy>

Normally the same way should allow to configure one of the other policies
[1].

Marc.

[1]
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/cookie/CookiePolicy.html
--
View this message in context: http://www.nabble.com/Change-Cookie-Policy-with-a-Groovy-step-t1474639.html#a3988557
Sent from the WebTest forum at Nabble.com.