[Webtest] Do cookies work?

Dierk Koenig localhost webtest@lists.canoo.com
Tue, 6 May 2003 09:34:52 +0200


Hi Alan,

Cookie handling (better: Session handling) is per TestSpec.
Every new TestSpec opens a new Session and therefore old Cookies are not
sent.

cheers
Mittie

> -----Original Message-----
> From: webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Alan Grover
> Sent: Freitag, 2. Mai 2003 19:25
> To: webtest@gate.canoo.com
> Subject: Re: [Webtest] Do cookies work?
>
>
> I was finally able to try this out (build 276). Below is the output
> from setLoggingHttpHeaders(true).
>
> Why doesn't webtest/httpunit send the cookie (step 3)? Browsers (IE &
> Mozilla) work. I tried changing the domain of the cookie, but that made
> no difference.
>
> 1. A 'clickbutton' posted to a page that requires a cookie, so the cgi
> redirects:
>   [testSpec] Setup.doExecute: acceptCookies = true
>
>   [testSpec] Header:: HTTP/1.0 302 Moved
>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:36 GMT
>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>   [testSpec] Header:: Location:
> http://dev6.office.techstreet.com/cgi-bin/
> sessioninit?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>   [testSpec] Header:: Content-Type: text/html
>
> 2. Webtest follows. Receiving a page with a cookie header. The page is
> a dumy, redirecting to a verifier ('sessionval'):
>
>   [testSpec] Sending:: User-Agent: httpunit/1.4
>   [testSpec] Sending:: Accept-Encoding: gzip
>   [testSpec] Header:: HTTP/1.0 302 Moved
>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:36 GMT
>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>   [testSpec] Header:: Set-Cookie:
> techstreet_dev6=YLJTHRKSHBNJMTZSMEFZIRLCVCFSRHNQTXJAOUSW;
> domain=dev6.office.techstreet.com; path=/
>   [testSpec] Header:: Location:
> http://dev6.office.techstreet.com/cgi-bin/
> sessionval?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>   [testSpec] Header:: Content-Type: text/html
>
> 3. Webtest follows, but doesn't send the cookie. The cgi at
> 'sessionval' returns (yet another redirect) to the "you need a cookie"
> page:
>
>   [testSpec] Sending:: User-Agent: httpunit/1.4
>   [testSpec] Sending:: Accept-Encoding: gzip
>   [testSpec] Header:: HTTP/1.0 302 Moved
>   [testSpec] Header:: Date: Fri, 02 May 2003 16:02:38 GMT
>   [testSpec] Header:: Server: Apache/1.3.19 (Unix) mod_perl/1.25
>   [testSpec] Header:: Location:
> http://dev6.office.techstreet.com/cgi-bin/
> sessionfail?return=http%3A%2F%2Fdev6.office.techstreet.com%2Fcgi-
> bin%2Fsubscriptions%2Fhttp%3A%2F%2Fdev6.office.techstreet.com
>   [testSpec] Header:: Content-Type: text/html
>   [testSpec] Sending:: User-Agent: httpunit/1.4
>   [testSpec] Sending:: Accept-Encoding: gzip
>
>
>
> On Wednesday, Apr 16, 2003, at 13:40 America/Detroit, Richard Hill
> wrote:
>
> > Alan,
> > com.canoo.webtest.steps.Setup has a method doExecute(Context context)
> > that
> > you can insert the httpunit option:
> >
> >     boolean acceptCookies = HttpUnitOptions.isAcceptCookies();
> >     System.out.println("Setup.doExecute: acceptCookies = " +
> > acceptCookies);
> >
> > This should let you know if httpunit is accepting cookies.
> >
> > You can also set the httpunit option:
> >
> >     HttpUnitOptions.setLoggingHttpHeaders(true);
> >
> > With this set you can see cookies being set or sent from httpunit as
> > the
> > test is running.
> >
> > Hope this helps,
> > - Richard
> >
> > -----Original Message-----
> > From: Alan Grover [mailto:awgrover@mail.msen.com]
> > Sent: Wednesday, April 09, 2003 7:13 AM
> > To: webtest@gate.canoo.com
> > Subject: [Webtest] Do cookies work?
> >
> >
> > Can anyone confirm that cookies are handled by webtest? Or, when they
> > aren't?
> > ---
> > Alan Grover
> > awgrover@mail.msen.com
> >
> > _______________________________________________
> > WebTest mailing list
> > WebTest@lists.canoo.com
> > http://lists.canoo.com/mailman/listinfo/webtest
> > _______________________________________________
> > WebTest mailing list
> > WebTest@lists.canoo.com
> > http://lists.canoo.com/mailman/listinfo/webtest
> >
> >
> ---
> Alan Grover
> awgrover@mail.msen.com
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>