You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Andrey Botalov <bo...@gmail.com> on 2012/12/04 22:03:36 UTC
How to set cookie that is usually set via Javascript?
Web application can set cookie via document.cookie.
It seems that HTTP Cookie Manager doesn't support this through User-defined
Cookies as such cookies are common to whole thread group.
How can I set such cookie?
Re: How to set cookie that is usually set via Javascript?
Posted by Andrey Botalov <bo...@gmail.com>.
On Wed, Dec 5, 2012 at 7:42 PM, Philippe Mouawad <philippe.mouawad@gmail.com
> wrote:
> And script must import classes used:
>
>
The issue was because I hadn't added imports
import org.apache.jmeter.protocol.http.control.CookieManager;
> import org.apache.jmeter.protocol.http.control.Cookie;
> CookieManager manager = sampler.getCookieManager();
> Cookie cookie = new Cookie("toto","titi","www.google.fr","/",false,0);
> manager.add(cookie);
>
> On Wed, Dec 5, 2012 at 5:41 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com
> > wrote:
>
> > Hello,
> > It works fine except for me, you must look in Request Tab.
> >
> > Regards
> > Philippe
> >
> >
> > On Wed, Dec 5, 2012 at 5:38 PM, Deepak Shetty <sh...@gmail.com> wrote:
> >
> >> Will have to check when I have access to a committee.did you import the
> >> classes? E.g. cookie? Jmeter.log may have errors check that too
> >> On Dec 5, 2012 2:37 AM, "Andrey Botalov" <bo...@gmail.com>
> >> wrote:
> >>
> >> > On Wed, Dec 5, 2012 at 12:11 AM, Deepak Shetty <sh...@gmail.com>
> >> wrote:
> >> >
> >> > > can be done in Beanshell or equivalent - get the cookie manager
> from
> >> the
> >> > > Sampler and add the cookie to it
> >> > >
> >> > >
> >> > >
> >> >
> >>
> http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
> >> > >
> >> > >
> >> > >
> >> > > I have the following structure:
> >> > HTTP Cookie Manager
> >> > Thread Group
> >> > Beanshell Preprocessor
> >> > HTTP Request (with server name www.google.com)
> >> > View Results Tree
> >> >
> >> > Beanshell Preprocessor has script:
> >> > manager = sampler.getCookieManager();
> >> > cookie = new Cookie("name","value","www.google.com
> >> ","/",false,2000000000);
> >> > manager.add(cookie);
> >> >
> >> > When I execute it no cookies are shown in View Results Tree
> >> >
> >> > >
> >> > >
> >> > > On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <
> >> botalov.andrey@gmail.com
> >> > > >wrote:
> >> > >
> >> > > > Web application can set cookie via document.cookie.
> >> > > >
> >> > > > It seems that HTTP Cookie Manager doesn't support this through
> >> > > User-defined
> >> > > > Cookies as such cookies are common to whole thread group.
> >> > > >
> >> > > > How can I set such cookie?
> >> > > >
> >> > >
> >> >
> >>
> >
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
> >
> >
> >
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
Re: How to set cookie that is usually set via Javascript?
Posted by Philippe Mouawad <ph...@gmail.com>.
And script must import classes used:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie("toto","titi","www.google.fr","/",false,0);
manager.add(cookie);
On Wed, Dec 5, 2012 at 5:41 PM, Philippe Mouawad <philippe.mouawad@gmail.com
> wrote:
> Hello,
> It works fine except for me, you must look in Request Tab.
>
> Regards
> Philippe
>
>
> On Wed, Dec 5, 2012 at 5:38 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
>> Will have to check when I have access to a committee.did you import the
>> classes? E.g. cookie? Jmeter.log may have errors check that too
>> On Dec 5, 2012 2:37 AM, "Andrey Botalov" <bo...@gmail.com>
>> wrote:
>>
>> > On Wed, Dec 5, 2012 at 12:11 AM, Deepak Shetty <sh...@gmail.com>
>> wrote:
>> >
>> > > can be done in Beanshell or equivalent - get the cookie manager from
>> the
>> > > Sampler and add the cookie to it
>> > >
>> > >
>> > >
>> >
>> http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
>> > >
>> > >
>> > >
>> > > I have the following structure:
>> > HTTP Cookie Manager
>> > Thread Group
>> > Beanshell Preprocessor
>> > HTTP Request (with server name www.google.com)
>> > View Results Tree
>> >
>> > Beanshell Preprocessor has script:
>> > manager = sampler.getCookieManager();
>> > cookie = new Cookie("name","value","www.google.com
>> ","/",false,2000000000);
>> > manager.add(cookie);
>> >
>> > When I execute it no cookies are shown in View Results Tree
>> >
>> > >
>> > >
>> > > On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <
>> botalov.andrey@gmail.com
>> > > >wrote:
>> > >
>> > > > Web application can set cookie via document.cookie.
>> > > >
>> > > > It seems that HTTP Cookie Manager doesn't support this through
>> > > User-defined
>> > > > Cookies as such cookies are common to whole thread group.
>> > > >
>> > > > How can I set such cookie?
>> > > >
>> > >
>> >
>>
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>
>
--
Cordialement.
Philippe Mouawad.
Re: How to set cookie that is usually set via Javascript?
Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
It works fine except for me, you must look in Request Tab.
Regards
Philippe
On Wed, Dec 5, 2012 at 5:38 PM, Deepak Shetty <sh...@gmail.com> wrote:
> Will have to check when I have access to a committee.did you import the
> classes? E.g. cookie? Jmeter.log may have errors check that too
> On Dec 5, 2012 2:37 AM, "Andrey Botalov" <bo...@gmail.com> wrote:
>
> > On Wed, Dec 5, 2012 at 12:11 AM, Deepak Shetty <sh...@gmail.com>
> wrote:
> >
> > > can be done in Beanshell or equivalent - get the cookie manager from
> the
> > > Sampler and add the cookie to it
> > >
> > >
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
> > >
> > >
> > >
> > > I have the following structure:
> > HTTP Cookie Manager
> > Thread Group
> > Beanshell Preprocessor
> > HTTP Request (with server name www.google.com)
> > View Results Tree
> >
> > Beanshell Preprocessor has script:
> > manager = sampler.getCookieManager();
> > cookie = new Cookie("name","value","www.google.com
> ","/",false,2000000000);
> > manager.add(cookie);
> >
> > When I execute it no cookies are shown in View Results Tree
> >
> > >
> > >
> > > On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <
> botalov.andrey@gmail.com
> > > >wrote:
> > >
> > > > Web application can set cookie via document.cookie.
> > > >
> > > > It seems that HTTP Cookie Manager doesn't support this through
> > > User-defined
> > > > Cookies as such cookies are common to whole thread group.
> > > >
> > > > How can I set such cookie?
> > > >
> > >
> >
>
--
Cordialement.
Philippe Mouawad.
Re: How to set cookie that is usually set via Javascript?
Posted by Deepak Shetty <sh...@gmail.com>.
Will have to check when I have access to a committee.did you import the
classes? E.g. cookie? Jmeter.log may have errors check that too
On Dec 5, 2012 2:37 AM, "Andrey Botalov" <bo...@gmail.com> wrote:
> On Wed, Dec 5, 2012 at 12:11 AM, Deepak Shetty <sh...@gmail.com> wrote:
>
> > can be done in Beanshell or equivalent - get the cookie manager from the
> > Sampler and add the cookie to it
> >
> >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
> >
> >
> >
> > I have the following structure:
> HTTP Cookie Manager
> Thread Group
> Beanshell Preprocessor
> HTTP Request (with server name www.google.com)
> View Results Tree
>
> Beanshell Preprocessor has script:
> manager = sampler.getCookieManager();
> cookie = new Cookie("name","value","www.google.com","/",false,2000000000);
> manager.add(cookie);
>
> When I execute it no cookies are shown in View Results Tree
>
> >
> >
> > On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <botalov.andrey@gmail.com
> > >wrote:
> >
> > > Web application can set cookie via document.cookie.
> > >
> > > It seems that HTTP Cookie Manager doesn't support this through
> > User-defined
> > > Cookies as such cookies are common to whole thread group.
> > >
> > > How can I set such cookie?
> > >
> >
>
Re: How to set cookie that is usually set via Javascript?
Posted by Andrey Botalov <bo...@gmail.com>.
On Wed, Dec 5, 2012 at 12:11 AM, Deepak Shetty <sh...@gmail.com> wrote:
> can be done in Beanshell or equivalent - get the cookie manager from the
> Sampler and add the cookie to it
>
>
> http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
>
>
>
> I have the following structure:
HTTP Cookie Manager
Thread Group
Beanshell Preprocessor
HTTP Request (with server name www.google.com)
View Results Tree
Beanshell Preprocessor has script:
manager = sampler.getCookieManager();
cookie = new Cookie("name","value","www.google.com","/",false,2000000000);
manager.add(cookie);
When I execute it no cookies are shown in View Results Tree
>
>
> On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <botalov.andrey@gmail.com
> >wrote:
>
> > Web application can set cookie via document.cookie.
> >
> > It seems that HTTP Cookie Manager doesn't support this through
> User-defined
> > Cookies as such cookies are common to whole thread group.
> >
> > How can I set such cookie?
> >
>
Re: How to set cookie that is usually set via Javascript?
Posted by Deepak Shetty <sh...@gmail.com>.
can be done in Beanshell or equivalent - get the cookie manager from the
Sampler and add the cookie to it
http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.html
On Tue, Dec 4, 2012 at 1:03 PM, Andrey Botalov <bo...@gmail.com>wrote:
> Web application can set cookie via document.cookie.
>
> It seems that HTTP Cookie Manager doesn't support this through User-defined
> Cookies as such cookies are common to whole thread group.
>
> How can I set such cookie?
>