On Thursday, August 30, 2012 at 8:22 PM, sebb wrote:
> On 30 August 2012 15:44, Morten Christensen (appinux)
> <[email protected] (mailto:[email protected])> 
> wrote:
> > Hi,
> > 
> > I am trying to extend JMeter with a custom login procedure that I have 
> > created using Http Client in a JavaSamplerClient. The custom login code 
> > creates 6 cookies on various domains and I want to add them to the JMeter's 
> > HTTP Cookie Manager that I have added to the Thread Group in my test plan 
> > in JMeter, so that subsequent HTTP REQUEST samplers will use them.
> 
> It's not clear why the existing HTTP Sampler cannot be used.
Because the login is for a very complex multi-domain App using a combination of 
POSTs, GETs, redirects and parsing/extracting about 30 hidden input fields 
across multiple domains for the HTTP operations I use. Took a full day 
constructing and validating about 100 lines of Java code with crazy stuff going 
on. Not pretty and certainly not something I would care to try or even consider 
doing in JMeter.
> > My problem is that I can't access the instance of the HTTP Cookie Manager 
> > that JMeter is using and can't find any documentation about what to do.
> 
> 
> The CM is only made available to the HTTP Samplers.
This I have found also. But is it unreasonable to want to extend the existing 
HTTP samplers with a Login sampler that works together with the existing ones ?
> 
> But you may find that variable references in the CM will pick up
> cookies stored as variables by the login code.
> 
> 

Yes, I saw something with CM and variables but I that CM and export to 
variables is not on by default. But if you think it is supported two-ways I 
might try to enable it and try. Not sure what I should call the variables 
though if the CM must be declared after my sampler runs etc. ?
> 
> > The provided JavaSamplerContext does not have anything of interest and nor 
> > does the JMeterContextService. I have also tried to cast the value of 
> > JMeterContextService.getContext().meterContext.getCurrentSampler().getProperty("HTTPSampler.cookie_manager")
> >  used by a source file I saw for the HTTP request but unfortunately this 
> > also did not work (returns null).
> > 
> > Any help will be much appreciated ? Alternatively, if it is impossible to 
> > create a simple JavaSamplerClient for custom cookie login, what is the 
> > recommended way?
> 
> What is it that the custom JavaSamplerClient does that the HTTP
> Sampler does not?
> 
> 

The HTTP Sampler seems to be useful for trivial login only. My login case is 
unfortunately VERY complex involving a session accross multiple domains 
controlled by 6 different cookies. Unfortunately, not something I can change. I 
can only test what is there (if I can login).
 
Thanks for your reply!!

/Morten

Reply via email to