You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Michael Sobczak <ms...@yahoo.com> on 2013/02/06 15:45:43 UTC

Accessing prev object as a DOM

Hi,

The API documentation states that there is an object called "prev" that I can access in a BSF Post Processor script.

What I'd like to do is use a BSF Post Processor to create a jMeter parameter based on the value of a field in the response.  If the field is empty, I need to assign a default value to the parameter.  If the field is not empty, I can save the field value in the parameter.

I'd like to use JavaScript in my BSF Post Processor.  How do I reference the document (or DOM) contained within the "prev" object?


Thanks,

- Mike.

Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Hi Shmuel,

Sorry, but that didn't really help me.  I know how to use Google, but not Regular Expressions.

I ultimately used a BSF Post Processor to check the value I originally extracted using the CSS/JQuery Extractor, and convert the variable value to "2" if it is blank.


Thanks,


- Mike.



________________________________
 From: Shmuel Krakower <sh...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com> 
Sent: Wednesday, February 6, 2013 4:10 PM
Subject: Re: Accessing prev object as a DOM
 
http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple

Shmuel Krakower.
www.Beatsoo.org - re-use your jmeter scripts for application performance
monitoring from worldwide locations for free.


On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi Deepak,
>
> I'm not very familiar with RegEx, so I was trying to stay with a language
> I can work with, like JavaScript or Java.
>
>
> How would I use RegEx to handle the following:
>
> If field is blank (or null) return "2"
>
> Else, return the field value.
>
>
>
> Thanks,
>
> - Mike.
>
>
>
> ________________________________
>  From: Deepak Shetty <sh...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> Sent: Wednesday, February 6, 2013 3:31 PM
> Subject: Re: Accessing prev object as a DOM
>
> Jmeter will give you the response as a string . if you wanted a DOM or
> something you'd have to parse it yourself(dont). The usual way to do
> something that you want is just use a regex post processor to extract what
> you need - which is simpler than coding it. Also any reason to prefer
> javascript over say java?
>
>
> On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi sebb,
> >
> > I'm new to jMeter, and I'm afraid I need more guidance.
> >
> > What would the Java code look like to do the following:
> >
> > 1) access prev object
> > 2) access document contained within prev object
> > 3) access an input field contained within the document
> >
> >
> >
> > Thanks,
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: sebb <se...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 2:57 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > > Sorry, I don't see how the Java API shows how to access SampleResult
> via
> > JavaScript.
> >
> > The JMeter code is written in Java, and Javadoc is the standard way to
> > document the methods.
> > Otherwise you can always look at the Java source file.
> >
> > > Can you provide an example?
> >
> > I don't know how Javascript calls external methods, but I would
> > imagine it looks much like Java.
> >
> > e.g. if var is a String, then var.length() would give the length.
> >
> > >
> > >
> > > ________________________________
> > >  From: sebb <se...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> > >> Hi,
> > >>
> > >> The API documentation states that there is an object called "prev"
> that
> > I can access in a BSF Post Processor script.
> > >>
> > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > parameter based on the value of a field in the response.  If the field is
> > empty, I need to assign a default value to the parameter.  If the field
> is
> > not empty, I can save the field value in the parameter.
> > >>
> > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > reference the document (or DOM) contained within the "prev" object?
> > >>
> > >
> > > The prev field is an instance of SampleResult [1] and so you can
> > > access any of its public methods.
> > >
> > > However, the Regulal Expression Extractor [2] is likely to be easier to
> > use.
> > > Or perhaps the CSS/JQuery or XPath extractor.
> > >
> > > [1]
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > [2]
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > >> Thanks,
> > >>
> > >> - Mike.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
>

Re: Accessing prev object as a DOM

Posted by Deepak Shetty <sh...@gmail.com>.
the regex i gave should work (it checks that there is atleast one character
between the "" - Theres probably a way to make the selector work as well
but i havent looked at it.


On Wed, Feb 6, 2013 at 5:36 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Yes, that was my issue.
>
>
>
>
> ________________________________
>  From: Deepak Shetty <sh...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>
> Sent: Wednesday, February 6, 2013 5:08 PM
> Subject: Re: Accessing prev object as a DOM
>
> Im guessing the issue he ran into is that the value is "" (empty string) -
> rather than non existent so it wouldnt pick the default.
>
>
> On Wed, Feb 6, 2013 at 1:53 PM, Philippe Mouawad <
> p.mouawad@ubik-ingenierie.com> wrote:
>
> > Hello,
> > If your requirement is the following:
> >
> >    - When extractor expression does not find any value, you set it to 2
> >
> > Then all you have to do is in this CSS/JQuery Extractor, set:
> >
> >    - Default Value : 2
> >
> > For the pageType story, you can use either Regexp or CSS then use an
> > IfController.
> >
> >
> > Clearly for performance of JMeter using javascript is not the best
> option.
> > If your test has limited number of threads it could be OK otherwise it's
> > better to try learning Regexp or CSS/JQuery, first is a good investment
> for
> > JMeter :-) .
> >
> > And I know specialists on this user mailing list who will be happy to
> help
> > you for complex issues :-)
> > Read this:
> >
> >    - http://jmeter.apache.org/usermanual/best-practices.html
> >    - http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/
> >
> >
> > Regards
> >
> > Philippe
> >
> >
> > UBIK-INGENIERIE on TWITTER <https://twitter.com/ubikingenierie>
> >
> > UBIK LOAD PACK BLOG <http://www.ubik-ingenierie.com/blog/>
> >
> > On Wed, Feb 6, 2013 at 10:40 PM, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> >
> > > Hi Philippe,
> > >
> > > What I wound up doing was add a BSF Post Processor.  It uses JavaScript
> > to
> > > check the variable to see if it is a null string.  If it is, it puts
> the
> > > variable back with a value of "2".  Probably not the best way to do
> this,
> > > but it got me past this problem.
> > >
> > > In my web site, there's a hidden input field called "pageType".  It can
> > > either contain a value or be empty.  The page also contains JavaScript
> > code
> > > that will get this field value and use it if it is not blank, or use
> "2"
> > > instead.  The JavaScript then changes the current page location to a
> new
> > > URL, using the pageType value as a query_string parameter.  What I was
> > > trying to do in jMeter was emulate the JavaScript that is executed on
> the
> > > page (since jMeter does not have the ability to interact dynamically
> > with a
> > > web page).  Does that help?
> > >
> > >
> > > - Mike.
> > >
> > >
> > >
> > > ________________________________
> > >  From: Philippe Mouawad <ph...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>
> > > Sent: Wednesday, February 6, 2013 4:14 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > Hello,
> > > From what I understand I think your can do what you want without BSF
> and
> > > scripting
> > >
> > > Didn't the CSS/JQuery post processor do this job ?
> > > Try to explain the whole process with sample data.
> > >
> > > Regards
> > > Philippe
> > >
> > > On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com>
> > > wrote:
> > >
> > > > http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
> > > >
> > > > Shmuel Krakower.
> > > > www.Beatsoo.org - re-use your jmeter scripts for application
> > performance
> > > > monitoring from worldwide locations for free.
> > > >
> > > >
> > > > On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <msobczak@yahoo.com
> >
> > > > wrote:
> > > >
> > > > > Hi Deepak,
> > > > >
> > > > > I'm not very familiar with RegEx, so I was trying to stay with a
> > > language
> > > > > I can work with, like JavaScript or Java.
> > > > >
> > > > >
> > > > > How would I use RegEx to handle the following:
> > > > >
> > > > > If field is blank (or null) return "2"
> > > > >
> > > > > Else, return the field value.
> > > > >
> > > > >
> > > > >
> > > > > Thanks,
> > > > >
> > > > > - Mike.
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > >  From: Deepak Shetty <sh...@gmail.com>
> > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > > msobczak@yahoo.com>
> > > > > Sent: Wednesday, February 6, 2013 3:31 PM
> > > > > Subject: Re: Accessing prev object as a DOM
> > > > >
> > > > > Jmeter will give you the response as a string . if you wanted a DOM
> > or
> > > > > something you'd have to parse it yourself(dont). The usual way to
> do
> > > > > something that you want is just use a regex post processor to
> extract
> > > > what
> > > > > you need - which is simpler than coding it. Also any reason to
> prefer
> > > > > javascript over say java?
> > > > >
> > > > >
> > > > > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <
> msobczak@yahoo.com
> > >
> > > > > wrote:
> > > > >
> > > > > > Hi sebb,
> > > > > >
> > > > > > I'm new to jMeter, and I'm afraid I need more guidance.
> > > > > >
> > > > > > What would the Java code look like to do the following:
> > > > > >
> > > > > > 1) access prev object
> > > > > > 2) access document contained within prev object
> > > > > > 3) access an input field contained within the document
> > > > > >
> > > > > >
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > - Mike.
> > > > > >
> > > > > >
> > > > > >
> > > > > > ________________________________
> > > > > >  From: sebb <se...@gmail.com>
> > > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak
> <
> > > > > > msobczak@yahoo.com>
> > > > > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > > > > Subject: Re: Accessing prev object as a DOM
> > > > > >
> > > > > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > > > > > > Sorry, I don't see how the Java API shows how to access
> > > SampleResult
> > > > > via
> > > > > > JavaScript.
> > > > > >
> > > > > > The JMeter code is written in Java, and Javadoc is the standard
> way
> > > to
> > > > > > document the methods.
> > > > > > Otherwise you can always look at the Java source file.
> > > > > >
> > > > > > > Can you provide an example?
> > > > > >
> > > > > > I don't know how Javascript calls external methods, but I would
> > > > > > imagine it looks much like Java.
> > > > > >
> > > > > > e.g. if var is a String, then var.length() would give the length.
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ________________________________
> > > > > > >  From: sebb <se...@gmail.com>
> > > > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael
> Sobczak
> > <
> > > > > > msobczak@yahoo.com>
> > > > > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > > > > Subject: Re: Accessing prev object as a DOM
> > > > > > >
> > > > > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> > > > wrote:
> > > > > > >> Hi,
> > > > > > >>
> > > > > > >> The API documentation states that there is an object called
> > "prev"
> > > > > that
> > > > > > I can access in a BSF Post Processor script.
> > > > > > >>
> > > > > > >> What I'd like to do is use a BSF Post Processor to create a
> > jMeter
> > > > > > parameter based on the value of a field in the response.  If the
> > > field
> > > > is
> > > > > > empty, I need to assign a default value to the parameter.  If the
> > > field
> > > > > is
> > > > > > not empty, I can save the field value in the parameter.
> > > > > > >>
> > > > > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > > > > reference the document (or DOM) contained within the "prev"
> object?
> > > > > > >>
> > > > > > >
> > > > > > > The prev field is an instance of SampleResult [1] and so you
> can
> > > > > > > access any of its public methods.
> > > > > > >
> > > > > > > However, the Regulal Expression Extractor [2] is likely to be
> > > easier
> > > > to
> > > > > > use.
> > > > > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > > > > >
> > > > > > > [1]
> > > > > >
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > > > > [2]
> > > > > >
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > > > > >> Thanks,
> > > > > > >>
> > > > > > >> - Mike.
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> >
> >
> >
> > --
> >
>

Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Yes, that was my issue.




________________________________
 From: Deepak Shetty <sh...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org> 
Sent: Wednesday, February 6, 2013 5:08 PM
Subject: Re: Accessing prev object as a DOM
 
Im guessing the issue he ran into is that the value is "" (empty string) -
rather than non existent so it wouldnt pick the default.


On Wed, Feb 6, 2013 at 1:53 PM, Philippe Mouawad <
p.mouawad@ubik-ingenierie.com> wrote:

> Hello,
> If your requirement is the following:
>
>    - When extractor expression does not find any value, you set it to 2
>
> Then all you have to do is in this CSS/JQuery Extractor, set:
>
>    - Default Value : 2
>
> For the pageType story, you can use either Regexp or CSS then use an
> IfController.
>
>
> Clearly for performance of JMeter using javascript is not the best option.
> If your test has limited number of threads it could be OK otherwise it's
> better to try learning Regexp or CSS/JQuery, first is a good investment for
> JMeter :-) .
>
> And I know specialists on this user mailing list who will be happy to help
> you for complex issues :-)
> Read this:
>
>    - http://jmeter.apache.org/usermanual/best-practices.html
>    - http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/
>
>
> Regards
>
> Philippe
>
>
> UBIK-INGENIERIE on TWITTER <https://twitter.com/ubikingenierie>
>
> UBIK LOAD PACK BLOG <http://www.ubik-ingenierie.com/blog/>
>
> On Wed, Feb 6, 2013 at 10:40 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi Philippe,
> >
> > What I wound up doing was add a BSF Post Processor.  It uses JavaScript
> to
> > check the variable to see if it is a null string.  If it is, it puts the
> > variable back with a value of "2".  Probably not the best way to do this,
> > but it got me past this problem.
> >
> > In my web site, there's a hidden input field called "pageType".  It can
> > either contain a value or be empty.  The page also contains JavaScript
> code
> > that will get this field value and use it if it is not blank, or use "2"
> > instead.  The JavaScript then changes the current page location to a new
> > URL, using the pageType value as a query_string parameter.  What I was
> > trying to do in jMeter was emulate the JavaScript that is executed on the
> > page (since jMeter does not have the ability to interact dynamically
> with a
> > web page).  Does that help?
> >
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: Philippe Mouawad <ph...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>
> > Sent: Wednesday, February 6, 2013 4:14 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > Hello,
> > From what I understand I think your can do what you want without BSF and
> > scripting
> >
> > Didn't the CSS/JQuery post processor do this job ?
> > Try to explain the whole process with sample data.
> >
> > Regards
> > Philippe
> >
> > On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com>
> > wrote:
> >
> > > http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
> > >
> > > Shmuel Krakower.
> > > www.Beatsoo.org - re-use your jmeter scripts for application
> performance
> > > monitoring from worldwide locations for free.
> > >
> > >
> > > On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > >
> > > > Hi Deepak,
> > > >
> > > > I'm not very familiar with RegEx, so I was trying to stay with a
> > language
> > > > I can work with, like JavaScript or Java.
> > > >
> > > >
> > > > How would I use RegEx to handle the following:
> > > >
> > > > If field is blank (or null) return "2"
> > > >
> > > > Else, return the field value.
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > - Mike.
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: Deepak Shetty <sh...@gmail.com>
> > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > msobczak@yahoo.com>
> > > > Sent: Wednesday, February 6, 2013 3:31 PM
> > > > Subject: Re: Accessing prev object as a DOM
> > > >
> > > > Jmeter will give you the response as a string . if you wanted a DOM
> or
> > > > something you'd have to parse it yourself(dont). The usual way to do
> > > > something that you want is just use a regex post processor to extract
> > > what
> > > > you need - which is simpler than coding it. Also any reason to prefer
> > > > javascript over say java?
> > > >
> > > >
> > > > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <msobczak@yahoo.com
> >
> > > > wrote:
> > > >
> > > > > Hi sebb,
> > > > >
> > > > > I'm new to jMeter, and I'm afraid I need more guidance.
> > > > >
> > > > > What would the Java code look like to do the following:
> > > > >
> > > > > 1) access prev object
> > > > > 2) access document contained within prev object
> > > > > 3) access an input field contained within the document
> > > > >
> > > > >
> > > > >
> > > > > Thanks,
> > > > >
> > > > > - Mike.
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > >  From: sebb <se...@gmail.com>
> > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > > msobczak@yahoo.com>
> > > > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > > > Subject: Re: Accessing prev object as a DOM
> > > > >
> > > > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> > > > > > Sorry, I don't see how the Java API shows how to access
> > SampleResult
> > > > via
> > > > > JavaScript.
> > > > >
> > > > > The JMeter code is written in Java, and Javadoc is the standard way
> > to
> > > > > document the methods.
> > > > > Otherwise you can always look at the Java source file.
> > > > >
> > > > > > Can you provide an example?
> > > > >
> > > > > I don't know how Javascript calls external methods, but I would
> > > > > imagine it looks much like Java.
> > > > >
> > > > > e.g. if var is a String, then var.length() would give the length.
> > > > >
> > > > > >
> > > > > >
> > > > > > ________________________________
> > > > > >  From: sebb <se...@gmail.com>
> > > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak
> <
> > > > > msobczak@yahoo.com>
> > > > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > > > Subject: Re: Accessing prev object as a DOM
> > > > > >
> > > > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > > > > >> Hi,
> > > > > >>
> > > > > >> The API documentation states that there is an object called
> "prev"
> > > > that
> > > > > I can access in a BSF Post Processor script.
> > > > > >>
> > > > > >> What I'd like to do is use a BSF Post Processor to create a
> jMeter
> > > > > parameter based on the value of a field in the response.  If the
> > field
> > > is
> > > > > empty, I need to assign a default value to the parameter.  If the
> > field
> > > > is
> > > > > not empty, I can save the field value in the parameter.
> > > > > >>
> > > > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > > > reference the document (or DOM) contained within the "prev" object?
> > > > > >>
> > > > > >
> > > > > > The prev field is an instance of SampleResult [1] and so you can
> > > > > > access any of its public methods.
> > > > > >
> > > > > > However, the Regulal Expression Extractor [2] is likely to be
> > easier
> > > to
> > > > > use.
> > > > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > > > >
> > > > > > [1]
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > > > [2]
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > > > >> Thanks,
> > > > > >>
> > > > > >> - Mike.
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
>
>
>
> --
>

Re: Accessing prev object as a DOM

Posted by Deepak Shetty <sh...@gmail.com>.
Im guessing the issue he ran into is that the value is "" (empty string) -
rather than non existent so it wouldnt pick the default.


On Wed, Feb 6, 2013 at 1:53 PM, Philippe Mouawad <
p.mouawad@ubik-ingenierie.com> wrote:

> Hello,
> If your requirement is the following:
>
>    - When extractor expression does not find any value, you set it to 2
>
> Then all you have to do is in this CSS/JQuery Extractor, set:
>
>    - Default Value : 2
>
> For the pageType story, you can use either Regexp or CSS then use an
> IfController.
>
>
> Clearly for performance of JMeter using javascript is not the best option.
> If your test has limited number of threads it could be OK otherwise it's
> better to try learning Regexp or CSS/JQuery, first is a good investment for
> JMeter :-) .
>
> And I know specialists on this user mailing list who will be happy to help
> you for complex issues :-)
> Read this:
>
>    - http://jmeter.apache.org/usermanual/best-practices.html
>    - http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/
>
>
> Regards
>
> Philippe
>
>
> UBIK-INGENIERIE on TWITTER <https://twitter.com/ubikingenierie>
>
> UBIK LOAD PACK BLOG <http://www.ubik-ingenierie.com/blog/>
>
> On Wed, Feb 6, 2013 at 10:40 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi Philippe,
> >
> > What I wound up doing was add a BSF Post Processor.  It uses JavaScript
> to
> > check the variable to see if it is a null string.  If it is, it puts the
> > variable back with a value of "2".  Probably not the best way to do this,
> > but it got me past this problem.
> >
> > In my web site, there's a hidden input field called "pageType".  It can
> > either contain a value or be empty.  The page also contains JavaScript
> code
> > that will get this field value and use it if it is not blank, or use "2"
> > instead.  The JavaScript then changes the current page location to a new
> > URL, using the pageType value as a query_string parameter.  What I was
> > trying to do in jMeter was emulate the JavaScript that is executed on the
> > page (since jMeter does not have the ability to interact dynamically
> with a
> > web page).  Does that help?
> >
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: Philippe Mouawad <ph...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>
> > Sent: Wednesday, February 6, 2013 4:14 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > Hello,
> > From what I understand I think your can do what you want without BSF and
> > scripting
> >
> > Didn't the CSS/JQuery post processor do this job ?
> > Try to explain the whole process with sample data.
> >
> > Regards
> > Philippe
> >
> > On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com>
> > wrote:
> >
> > > http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
> > >
> > > Shmuel Krakower.
> > > www.Beatsoo.org - re-use your jmeter scripts for application
> performance
> > > monitoring from worldwide locations for free.
> > >
> > >
> > > On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > >
> > > > Hi Deepak,
> > > >
> > > > I'm not very familiar with RegEx, so I was trying to stay with a
> > language
> > > > I can work with, like JavaScript or Java.
> > > >
> > > >
> > > > How would I use RegEx to handle the following:
> > > >
> > > > If field is blank (or null) return "2"
> > > >
> > > > Else, return the field value.
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > - Mike.
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: Deepak Shetty <sh...@gmail.com>
> > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > msobczak@yahoo.com>
> > > > Sent: Wednesday, February 6, 2013 3:31 PM
> > > > Subject: Re: Accessing prev object as a DOM
> > > >
> > > > Jmeter will give you the response as a string . if you wanted a DOM
> or
> > > > something you'd have to parse it yourself(dont). The usual way to do
> > > > something that you want is just use a regex post processor to extract
> > > what
> > > > you need - which is simpler than coding it. Also any reason to prefer
> > > > javascript over say java?
> > > >
> > > >
> > > > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <msobczak@yahoo.com
> >
> > > > wrote:
> > > >
> > > > > Hi sebb,
> > > > >
> > > > > I'm new to jMeter, and I'm afraid I need more guidance.
> > > > >
> > > > > What would the Java code look like to do the following:
> > > > >
> > > > > 1) access prev object
> > > > > 2) access document contained within prev object
> > > > > 3) access an input field contained within the document
> > > > >
> > > > >
> > > > >
> > > > > Thanks,
> > > > >
> > > > > - Mike.
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > >  From: sebb <se...@gmail.com>
> > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > > msobczak@yahoo.com>
> > > > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > > > Subject: Re: Accessing prev object as a DOM
> > > > >
> > > > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> > > > > > Sorry, I don't see how the Java API shows how to access
> > SampleResult
> > > > via
> > > > > JavaScript.
> > > > >
> > > > > The JMeter code is written in Java, and Javadoc is the standard way
> > to
> > > > > document the methods.
> > > > > Otherwise you can always look at the Java source file.
> > > > >
> > > > > > Can you provide an example?
> > > > >
> > > > > I don't know how Javascript calls external methods, but I would
> > > > > imagine it looks much like Java.
> > > > >
> > > > > e.g. if var is a String, then var.length() would give the length.
> > > > >
> > > > > >
> > > > > >
> > > > > > ________________________________
> > > > > >  From: sebb <se...@gmail.com>
> > > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak
> <
> > > > > msobczak@yahoo.com>
> > > > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > > > Subject: Re: Accessing prev object as a DOM
> > > > > >
> > > > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > > > > >> Hi,
> > > > > >>
> > > > > >> The API documentation states that there is an object called
> "prev"
> > > > that
> > > > > I can access in a BSF Post Processor script.
> > > > > >>
> > > > > >> What I'd like to do is use a BSF Post Processor to create a
> jMeter
> > > > > parameter based on the value of a field in the response.  If the
> > field
> > > is
> > > > > empty, I need to assign a default value to the parameter.  If the
> > field
> > > > is
> > > > > not empty, I can save the field value in the parameter.
> > > > > >>
> > > > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > > > reference the document (or DOM) contained within the "prev" object?
> > > > > >>
> > > > > >
> > > > > > The prev field is an instance of SampleResult [1] and so you can
> > > > > > access any of its public methods.
> > > > > >
> > > > > > However, the Regulal Expression Extractor [2] is likely to be
> > easier
> > > to
> > > > > use.
> > > > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > > > >
> > > > > > [1]
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > > > [2]
> > > > >
> > > >
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > > > >> Thanks,
> > > > > >>
> > > > > >> - Mike.
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
>
>
>
> --
>

Re: Accessing prev object as a DOM

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
Hello,
If your requirement is the following:

   - When extractor expression does not find any value, you set it to 2

Then all you have to do is in this CSS/JQuery Extractor, set:

   - Default Value : 2

For the pageType story, you can use either Regexp or CSS then use an
IfController.


Clearly for performance of JMeter using javascript is not the best option.
If your test has limited number of threads it could be OK otherwise it's
better to try learning Regexp or CSS/JQuery, first is a good investment for
JMeter :-) .

And I know specialists on this user mailing list who will be happy to help
you for complex issues :-)
Read this:

   - http://jmeter.apache.org/usermanual/best-practices.html
   - http://www.ubik-ingenierie.com/blog/jmeter_performance_tuning_tips/


Regards

Philippe


UBIK-INGENIERIE on TWITTER <https://twitter.com/ubikingenierie>

UBIK LOAD PACK BLOG <http://www.ubik-ingenierie.com/blog/>

On Wed, Feb 6, 2013 at 10:40 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi Philippe,
>
> What I wound up doing was add a BSF Post Processor.  It uses JavaScript to
> check the variable to see if it is a null string.  If it is, it puts the
> variable back with a value of "2".  Probably not the best way to do this,
> but it got me past this problem.
>
> In my web site, there's a hidden input field called "pageType".  It can
> either contain a value or be empty.  The page also contains JavaScript code
> that will get this field value and use it if it is not blank, or use "2"
> instead.  The JavaScript then changes the current page location to a new
> URL, using the pageType value as a query_string parameter.  What I was
> trying to do in jMeter was emulate the JavaScript that is executed on the
> page (since jMeter does not have the ability to interact dynamically with a
> web page).  Does that help?
>
>
> - Mike.
>
>
>
> ________________________________
>  From: Philippe Mouawad <ph...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>
> Sent: Wednesday, February 6, 2013 4:14 PM
> Subject: Re: Accessing prev object as a DOM
>
> Hello,
> From what I understand I think your can do what you want without BSF and
> scripting
>
> Didn't the CSS/JQuery post processor do this job ?
> Try to explain the whole process with sample data.
>
> Regards
> Philippe
>
> On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com>
> wrote:
>
> > http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
> >
> > Shmuel Krakower.
> > www.Beatsoo.org - re-use your jmeter scripts for application performance
> > monitoring from worldwide locations for free.
> >
> >
> > On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> >
> > > Hi Deepak,
> > >
> > > I'm not very familiar with RegEx, so I was trying to stay with a
> language
> > > I can work with, like JavaScript or Java.
> > >
> > >
> > > How would I use RegEx to handle the following:
> > >
> > > If field is blank (or null) return "2"
> > >
> > > Else, return the field value.
> > >
> > >
> > >
> > > Thanks,
> > >
> > > - Mike.
> > >
> > >
> > >
> > > ________________________________
> > >  From: Deepak Shetty <sh...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 3:31 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > Jmeter will give you the response as a string . if you wanted a DOM or
> > > something you'd have to parse it yourself(dont). The usual way to do
> > > something that you want is just use a regex post processor to extract
> > what
> > > you need - which is simpler than coding it. Also any reason to prefer
> > > javascript over say java?
> > >
> > >
> > > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> > > wrote:
> > >
> > > > Hi sebb,
> > > >
> > > > I'm new to jMeter, and I'm afraid I need more guidance.
> > > >
> > > > What would the Java code look like to do the following:
> > > >
> > > > 1) access prev object
> > > > 2) access document contained within prev object
> > > > 3) access an input field contained within the document
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > - Mike.
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: sebb <se...@gmail.com>
> > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > msobczak@yahoo.com>
> > > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > > Subject: Re: Accessing prev object as a DOM
> > > >
> > > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com>
> wrote:
> > > > > Sorry, I don't see how the Java API shows how to access
> SampleResult
> > > via
> > > > JavaScript.
> > > >
> > > > The JMeter code is written in Java, and Javadoc is the standard way
> to
> > > > document the methods.
> > > > Otherwise you can always look at the Java source file.
> > > >
> > > > > Can you provide an example?
> > > >
> > > > I don't know how Javascript calls external methods, but I would
> > > > imagine it looks much like Java.
> > > >
> > > > e.g. if var is a String, then var.length() would give the length.
> > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > >  From: sebb <se...@gmail.com>
> > > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > > msobczak@yahoo.com>
> > > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > > Subject: Re: Accessing prev object as a DOM
> > > > >
> > > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> > > > >> Hi,
> > > > >>
> > > > >> The API documentation states that there is an object called "prev"
> > > that
> > > > I can access in a BSF Post Processor script.
> > > > >>
> > > > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > > > parameter based on the value of a field in the response.  If the
> field
> > is
> > > > empty, I need to assign a default value to the parameter.  If the
> field
> > > is
> > > > not empty, I can save the field value in the parameter.
> > > > >>
> > > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > > reference the document (or DOM) contained within the "prev" object?
> > > > >>
> > > > >
> > > > > The prev field is an instance of SampleResult [1] and so you can
> > > > > access any of its public methods.
> > > > >
> > > > > However, the Regulal Expression Extractor [2] is likely to be
> easier
> > to
> > > > use.
> > > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > > >
> > > > > [1]
> > > >
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > > [2]
> > > >
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > > >> Thanks,
> > > > >>
> > > > >> - Mike.
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > > >
> > >
> >
>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>



--

Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Hi Philippe,

What I wound up doing was add a BSF Post Processor.  It uses JavaScript to check the variable to see if it is a null string.  If it is, it puts the variable back with a value of "2".  Probably not the best way to do this, but it got me past this problem.

In my web site, there's a hidden input field called "pageType".  It can either contain a value or be empty.  The page also contains JavaScript code that will get this field value and use it if it is not blank, or use "2" instead.  The JavaScript then changes the current page location to a new URL, using the pageType value as a query_string parameter.  What I was trying to do in jMeter was emulate the JavaScript that is executed on the page (since jMeter does not have the ability to interact dynamically with a web page).  Does that help?


- Mike.



________________________________
 From: Philippe Mouawad <ph...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org> 
Sent: Wednesday, February 6, 2013 4:14 PM
Subject: Re: Accessing prev object as a DOM
 
Hello,
From what I understand I think your can do what you want without BSF and
scripting

Didn't the CSS/JQuery post processor do this job ?
Try to explain the whole process with sample data.

Regards
Philippe

On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com> wrote:

> http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
>
> Shmuel Krakower.
> www.Beatsoo.org - re-use your jmeter scripts for application performance
> monitoring from worldwide locations for free.
>
>
> On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi Deepak,
> >
> > I'm not very familiar with RegEx, so I was trying to stay with a language
> > I can work with, like JavaScript or Java.
> >
> >
> > How would I use RegEx to handle the following:
> >
> > If field is blank (or null) return "2"
> >
> > Else, return the field value.
> >
> >
> >
> > Thanks,
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: Deepak Shetty <sh...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 3:31 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > Jmeter will give you the response as a string . if you wanted a DOM or
> > something you'd have to parse it yourself(dont). The usual way to do
> > something that you want is just use a regex post processor to extract
> what
> > you need - which is simpler than coding it. Also any reason to prefer
> > javascript over say java?
> >
> >
> > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> >
> > > Hi sebb,
> > >
> > > I'm new to jMeter, and I'm afraid I need more guidance.
> > >
> > > What would the Java code look like to do the following:
> > >
> > > 1) access prev object
> > > 2) access document contained within prev object
> > > 3) access an input field contained within the document
> > >
> > >
> > >
> > > Thanks,
> > >
> > > - Mike.
> > >
> > >
> > >
> > > ________________________________
> > >  From: sebb <se...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > > > Sorry, I don't see how the Java API shows how to access SampleResult
> > via
> > > JavaScript.
> > >
> > > The JMeter code is written in Java, and Javadoc is the standard way to
> > > document the methods.
> > > Otherwise you can always look at the Java source file.
> > >
> > > > Can you provide an example?
> > >
> > > I don't know how Javascript calls external methods, but I would
> > > imagine it looks much like Java.
> > >
> > > e.g. if var is a String, then var.length() would give the length.
> > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: sebb <se...@gmail.com>
> > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > msobczak@yahoo.com>
> > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > Subject: Re: Accessing prev object as a DOM
> > > >
> > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> wrote:
> > > >> Hi,
> > > >>
> > > >> The API documentation states that there is an object called "prev"
> > that
> > > I can access in a BSF Post Processor script.
> > > >>
> > > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > > parameter based on the value of a field in the response.  If the field
> is
> > > empty, I need to assign a default value to the parameter.  If the field
> > is
> > > not empty, I can save the field value in the parameter.
> > > >>
> > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > reference the document (or DOM) contained within the "prev" object?
> > > >>
> > > >
> > > > The prev field is an instance of SampleResult [1] and so you can
> > > > access any of its public methods.
> > > >
> > > > However, the Regulal Expression Extractor [2] is likely to be easier
> to
> > > use.
> > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > >
> > > > [1]
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > [2]
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > >> Thanks,
> > > >>
> > > >> - Mike.
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> > >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Re: Accessing prev object as a DOM

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello,
>From what I understand I think your can do what you want without BSF and
scripting

Didn't the CSS/JQuery post processor do this job ?
Try to explain the whole process with sample data.

Regards
Philippe

On Wed, Feb 6, 2013 at 10:10 PM, Shmuel Krakower <sh...@gmail.com> wrote:

> http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple
>
> Shmuel Krakower.
> www.Beatsoo.org - re-use your jmeter scripts for application performance
> monitoring from worldwide locations for free.
>
>
> On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi Deepak,
> >
> > I'm not very familiar with RegEx, so I was trying to stay with a language
> > I can work with, like JavaScript or Java.
> >
> >
> > How would I use RegEx to handle the following:
> >
> > If field is blank (or null) return "2"
> >
> > Else, return the field value.
> >
> >
> >
> > Thanks,
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: Deepak Shetty <sh...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 3:31 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > Jmeter will give you the response as a string . if you wanted a DOM or
> > something you'd have to parse it yourself(dont). The usual way to do
> > something that you want is just use a regex post processor to extract
> what
> > you need - which is simpler than coding it. Also any reason to prefer
> > javascript over say java?
> >
> >
> > On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> > wrote:
> >
> > > Hi sebb,
> > >
> > > I'm new to jMeter, and I'm afraid I need more guidance.
> > >
> > > What would the Java code look like to do the following:
> > >
> > > 1) access prev object
> > > 2) access document contained within prev object
> > > 3) access an input field contained within the document
> > >
> > >
> > >
> > > Thanks,
> > >
> > > - Mike.
> > >
> > >
> > >
> > > ________________________________
> > >  From: sebb <se...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 2:57 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > > > Sorry, I don't see how the Java API shows how to access SampleResult
> > via
> > > JavaScript.
> > >
> > > The JMeter code is written in Java, and Javadoc is the standard way to
> > > document the methods.
> > > Otherwise you can always look at the Java source file.
> > >
> > > > Can you provide an example?
> > >
> > > I don't know how Javascript calls external methods, but I would
> > > imagine it looks much like Java.
> > >
> > > e.g. if var is a String, then var.length() would give the length.
> > >
> > > >
> > > >
> > > > ________________________________
> > > >  From: sebb <se...@gmail.com>
> > > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > > msobczak@yahoo.com>
> > > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > > Subject: Re: Accessing prev object as a DOM
> > > >
> > > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com>
> wrote:
> > > >> Hi,
> > > >>
> > > >> The API documentation states that there is an object called "prev"
> > that
> > > I can access in a BSF Post Processor script.
> > > >>
> > > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > > parameter based on the value of a field in the response.  If the field
> is
> > > empty, I need to assign a default value to the parameter.  If the field
> > is
> > > not empty, I can save the field value in the parameter.
> > > >>
> > > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > > reference the document (or DOM) contained within the "prev" object?
> > > >>
> > > >
> > > > The prev field is an instance of SampleResult [1] and so you can
> > > > access any of its public methods.
> > > >
> > > > However, the Regulal Expression Extractor [2] is likely to be easier
> to
> > > use.
> > > > Or perhaps the CSS/JQuery or XPath extractor.
> > > >
> > > > [1]
> > >
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > > [2]
> > >
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > > >> Thanks,
> > > >>
> > > >> - Mike.
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > > For additional commands, e-mail: user-help@jmeter.apache.org
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> > >
> >
>



-- 
Cordialement.
Philippe Mouawad.

Re: Accessing prev object as a DOM

Posted by Shmuel Krakower <sh...@gmail.com>.
http://lmgtfy.com/?q=jmeter+regex+extractor+exmaple

Shmuel Krakower.
www.Beatsoo.org - re-use your jmeter scripts for application performance
monitoring from worldwide locations for free.


On Wed, Feb 6, 2013 at 10:35 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi Deepak,
>
> I'm not very familiar with RegEx, so I was trying to stay with a language
> I can work with, like JavaScript or Java.
>
>
> How would I use RegEx to handle the following:
>
> If field is blank (or null) return "2"
>
> Else, return the field value.
>
>
>
> Thanks,
>
> - Mike.
>
>
>
> ________________________________
>  From: Deepak Shetty <sh...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> Sent: Wednesday, February 6, 2013 3:31 PM
> Subject: Re: Accessing prev object as a DOM
>
> Jmeter will give you the response as a string . if you wanted a DOM or
> something you'd have to parse it yourself(dont). The usual way to do
> something that you want is just use a regex post processor to extract what
> you need - which is simpler than coding it. Also any reason to prefer
> javascript over say java?
>
>
> On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi sebb,
> >
> > I'm new to jMeter, and I'm afraid I need more guidance.
> >
> > What would the Java code look like to do the following:
> >
> > 1) access prev object
> > 2) access document contained within prev object
> > 3) access an input field contained within the document
> >
> >
> >
> > Thanks,
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: sebb <se...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 2:57 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > > Sorry, I don't see how the Java API shows how to access SampleResult
> via
> > JavaScript.
> >
> > The JMeter code is written in Java, and Javadoc is the standard way to
> > document the methods.
> > Otherwise you can always look at the Java source file.
> >
> > > Can you provide an example?
> >
> > I don't know how Javascript calls external methods, but I would
> > imagine it looks much like Java.
> >
> > e.g. if var is a String, then var.length() would give the length.
> >
> > >
> > >
> > > ________________________________
> > >  From: sebb <se...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> > >> Hi,
> > >>
> > >> The API documentation states that there is an object called "prev"
> that
> > I can access in a BSF Post Processor script.
> > >>
> > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > parameter based on the value of a field in the response.  If the field is
> > empty, I need to assign a default value to the parameter.  If the field
> is
> > not empty, I can save the field value in the parameter.
> > >>
> > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > reference the document (or DOM) contained within the "prev" object?
> > >>
> > >
> > > The prev field is an instance of SampleResult [1] and so you can
> > > access any of its public methods.
> > >
> > > However, the Regulal Expression Extractor [2] is likely to be easier to
> > use.
> > > Or perhaps the CSS/JQuery or XPath extractor.
> > >
> > > [1]
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > [2]
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > >> Thanks,
> > >>
> > >> - Mike.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
>

Re: Accessing prev object as a DOM

Posted by Deepak Shetty <sh...@gmail.com>.
You'd extract out the value of the input using a regex  (given the name).
and give a default value of 2
so if your HTML response had something like
<input name="x" value="somevalue" .../> and/or
<input name="x" value="" .../>
 Then your regex would be <input\s+name="x"\s+value="([^"]+)"
Template would be $1$
Match No 0
Default Value : 2

Regex's are too powerful a tool to not know (both in development and
testing). if you have more complicated requirements then regex's may not
work - but java should and you can use the javadoc provided - *
getResponseDataAsString<http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html#getResponseDataAsString%28%29>
*() should give you the text of the response for you to work on.

regards
deepak




On Wed, Feb 6, 2013 at 12:35 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi Deepak,
>
> I'm not very familiar with RegEx, so I was trying to stay with a language
> I can work with, like JavaScript or Java.
>
>
> How would I use RegEx to handle the following:
>
> If field is blank (or null) return "2"
>
> Else, return the field value.
>
>
>
> Thanks,
>
> - Mike.
>
>
>
> ________________________________
>  From: Deepak Shetty <sh...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> Sent: Wednesday, February 6, 2013 3:31 PM
> Subject: Re: Accessing prev object as a DOM
>
> Jmeter will give you the response as a string . if you wanted a DOM or
> something you'd have to parse it yourself(dont). The usual way to do
> something that you want is just use a regex post processor to extract what
> you need - which is simpler than coding it. Also any reason to prefer
> javascript over say java?
>
>
> On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com>
> wrote:
>
> > Hi sebb,
> >
> > I'm new to jMeter, and I'm afraid I need more guidance.
> >
> > What would the Java code look like to do the following:
> >
> > 1) access prev object
> > 2) access document contained within prev object
> > 3) access an input field contained within the document
> >
> >
> >
> > Thanks,
> >
> > - Mike.
> >
> >
> >
> > ________________________________
> >  From: sebb <se...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 2:57 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > > Sorry, I don't see how the Java API shows how to access SampleResult
> via
> > JavaScript.
> >
> > The JMeter code is written in Java, and Javadoc is the standard way to
> > document the methods.
> > Otherwise you can always look at the Java source file.
> >
> > > Can you provide an example?
> >
> > I don't know how Javascript calls external methods, but I would
> > imagine it looks much like Java.
> >
> > e.g. if var is a String, then var.length() would give the length.
> >
> > >
> > >
> > > ________________________________
> > >  From: sebb <se...@gmail.com>
> > > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> > msobczak@yahoo.com>
> > > Sent: Wednesday, February 6, 2013 2:05 PM
> > > Subject: Re: Accessing prev object as a DOM
> > >
> > > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> > >> Hi,
> > >>
> > >> The API documentation states that there is an object called "prev"
> that
> > I can access in a BSF Post Processor script.
> > >>
> > >> What I'd like to do is use a BSF Post Processor to create a jMeter
> > parameter based on the value of a field in the response.  If the field is
> > empty, I need to assign a default value to the parameter.  If the field
> is
> > not empty, I can save the field value in the parameter.
> > >>
> > >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> > reference the document (or DOM) contained within the "prev" object?
> > >>
> > >
> > > The prev field is an instance of SampleResult [1] and so you can
> > > access any of its public methods.
> > >
> > > However, the Regulal Expression Extractor [2] is likely to be easier to
> > use.
> > > Or perhaps the CSS/JQuery or XPath extractor.
> > >
> > > [1]
> >
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > > [2]
> >
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> > >> Thanks,
> > >>
> > >> - Mike.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > > For additional commands, e-mail: user-help@jmeter.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
> >
>

Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Hi Deepak,

I'm not very familiar with RegEx, so I was trying to stay with a language I can work with, like JavaScript or Java.


How would I use RegEx to handle the following:

If field is blank (or null) return "2"

Else, return the field value.



Thanks,

- Mike.



________________________________
 From: Deepak Shetty <sh...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com> 
Sent: Wednesday, February 6, 2013 3:31 PM
Subject: Re: Accessing prev object as a DOM
 
Jmeter will give you the response as a string . if you wanted a DOM or
something you'd have to parse it yourself(dont). The usual way to do
something that you want is just use a regex post processor to extract what
you need - which is simpler than coding it. Also any reason to prefer
javascript over say java?


On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi sebb,
>
> I'm new to jMeter, and I'm afraid I need more guidance.
>
> What would the Java code look like to do the following:
>
> 1) access prev object
> 2) access document contained within prev object
> 3) access an input field contained within the document
>
>
>
> Thanks,
>
> - Mike.
>
>
>
> ________________________________
>  From: sebb <se...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> Sent: Wednesday, February 6, 2013 2:57 PM
> Subject: Re: Accessing prev object as a DOM
>
> On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > Sorry, I don't see how the Java API shows how to access SampleResult via
> JavaScript.
>
> The JMeter code is written in Java, and Javadoc is the standard way to
> document the methods.
> Otherwise you can always look at the Java source file.
>
> > Can you provide an example?
>
> I don't know how Javascript calls external methods, but I would
> imagine it looks much like Java.
>
> e.g. if var is a String, then var.length() would give the length.
>
> >
> >
> > ________________________________
> >  From: sebb <se...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 2:05 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> >> Hi,
> >>
> >> The API documentation states that there is an object called "prev" that
> I can access in a BSF Post Processor script.
> >>
> >> What I'd like to do is use a BSF Post Processor to create a jMeter
> parameter based on the value of a field in the response.  If the field is
> empty, I need to assign a default value to the parameter.  If the field is
> not empty, I can save the field value in the parameter.
> >>
> >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> reference the document (or DOM) contained within the "prev" object?
> >>
> >
> > The prev field is an instance of SampleResult [1] and so you can
> > access any of its public methods.
> >
> > However, the Regulal Expression Extractor [2] is likely to be easier to
> use.
> > Or perhaps the CSS/JQuery or XPath extractor.
> >
> > [1]
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > [2]
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> >> Thanks,
> >>
> >> - Mike.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

Re: Accessing prev object as a DOM

Posted by Deepak Shetty <sh...@gmail.com>.
Jmeter will give you the response as a string . if you wanted a DOM or
something you'd have to parse it yourself(dont). The usual way to do
something that you want is just use a regex post processor to extract what
you need - which is simpler than coding it. Also any reason to prefer
javascript over say java?


On Wed, Feb 6, 2013 at 12:21 PM, Michael Sobczak <ms...@yahoo.com> wrote:

> Hi sebb,
>
> I'm new to jMeter, and I'm afraid I need more guidance.
>
> What would the Java code look like to do the following:
>
> 1) access prev object
> 2) access document contained within prev object
> 3) access an input field contained within the document
>
>
>
> Thanks,
>
> - Mike.
>
>
>
> ________________________________
>  From: sebb <se...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> Sent: Wednesday, February 6, 2013 2:57 PM
> Subject: Re: Accessing prev object as a DOM
>
> On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> > Sorry, I don't see how the Java API shows how to access SampleResult via
> JavaScript.
>
> The JMeter code is written in Java, and Javadoc is the standard way to
> document the methods.
> Otherwise you can always look at the Java source file.
>
> > Can you provide an example?
>
> I don't know how Javascript calls external methods, but I would
> imagine it looks much like Java.
>
> e.g. if var is a String, then var.length() would give the length.
>
> >
> >
> > ________________________________
> >  From: sebb <se...@gmail.com>
> > To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <
> msobczak@yahoo.com>
> > Sent: Wednesday, February 6, 2013 2:05 PM
> > Subject: Re: Accessing prev object as a DOM
> >
> > On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> >> Hi,
> >>
> >> The API documentation states that there is an object called "prev" that
> I can access in a BSF Post Processor script.
> >>
> >> What I'd like to do is use a BSF Post Processor to create a jMeter
> parameter based on the value of a field in the response.  If the field is
> empty, I need to assign a default value to the parameter.  If the field is
> not empty, I can save the field value in the parameter.
> >>
> >> I'd like to use JavaScript in my BSF Post Processor.  How do I
> reference the document (or DOM) contained within the "prev" object?
> >>
> >
> > The prev field is an instance of SampleResult [1] and so you can
> > access any of its public methods.
> >
> > However, the Regulal Expression Extractor [2] is likely to be easier to
> use.
> > Or perhaps the CSS/JQuery or XPath extractor.
> >
> > [1]
> http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> > [2]
> http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> >> Thanks,
> >>
> >> - Mike.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> > For additional commands, e-mail: user-help@jmeter.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Hi sebb,

I'm new to jMeter, and I'm afraid I need more guidance.

What would the Java code look like to do the following:

1) access prev object
2) access document contained within prev object
3) access an input field contained within the document



Thanks,

- Mike.



________________________________
 From: sebb <se...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com> 
Sent: Wednesday, February 6, 2013 2:57 PM
Subject: Re: Accessing prev object as a DOM
 
On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> Sorry, I don't see how the Java API shows how to access SampleResult via JavaScript.

The JMeter code is written in Java, and Javadoc is the standard way to
document the methods.
Otherwise you can always look at the Java source file.

> Can you provide an example?

I don't know how Javascript calls external methods, but I would
imagine it looks much like Java.

e.g. if var is a String, then var.length() would give the length.

>
>
> ________________________________
>  From: sebb <se...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com>
> Sent: Wednesday, February 6, 2013 2:05 PM
> Subject: Re: Accessing prev object as a DOM
>
> On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
>> Hi,
>>
>> The API documentation states that there is an object called "prev" that I can access in a BSF Post Processor script.
>>
>> What I'd like to do is use a BSF Post Processor to create a jMeter parameter based on the value of a field in the response.  If the field is empty, I need to assign a default value to the parameter.  If the field is not empty, I can save the field value in the parameter.
>>
>> I'd like to use JavaScript in my BSF Post Processor.  How do I reference the document (or DOM) contained within the "prev" object?
>>
>
> The prev field is an instance of SampleResult [1] and so you can
> access any of its public methods.
>
> However, the Regulal Expression Extractor [2] is likely to be easier to use.
> Or perhaps the CSS/JQuery or XPath extractor.
>
> [1] http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> [2] http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
>> Thanks,
>>
>> - Mike.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org

Re: Accessing prev object as a DOM

Posted by sebb <se...@gmail.com>.
On 6 February 2013 19:33, Michael Sobczak <ms...@yahoo.com> wrote:
> Sorry, I don't see how the Java API shows how to access SampleResult via JavaScript.

The JMeter code is written in Java, and Javadoc is the standard way to
document the methods.
Otherwise you can always look at the Java source file.

> Can you provide an example?

I don't know how Javascript calls external methods, but I would
imagine it looks much like Java.

e.g. if var is a String, then var.length() would give the length.

>
>
> ________________________________
>  From: sebb <se...@gmail.com>
> To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com>
> Sent: Wednesday, February 6, 2013 2:05 PM
> Subject: Re: Accessing prev object as a DOM
>
> On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
>> Hi,
>>
>> The API documentation states that there is an object called "prev" that I can access in a BSF Post Processor script.
>>
>> What I'd like to do is use a BSF Post Processor to create a jMeter parameter based on the value of a field in the response.  If the field is empty, I need to assign a default value to the parameter.  If the field is not empty, I can save the field value in the parameter.
>>
>> I'd like to use JavaScript in my BSF Post Processor.  How do I reference the document (or DOM) contained within the "prev" object?
>>
>
> The prev field is an instance of SampleResult [1] and so you can
> access any of its public methods.
>
> However, the Regulal Expression Extractor [2] is likely to be easier to use.
> Or perhaps the CSS/JQuery or XPath extractor.
>
> [1] http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
> [2] http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
>> Thanks,
>>
>> - Mike.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: Accessing prev object as a DOM

Posted by Michael Sobczak <ms...@yahoo.com>.
Sorry, I don't see how the Java API shows how to access SampleResult via JavaScript.

Can you provide an example?




________________________________
 From: sebb <se...@gmail.com>
To: JMeter Users List <us...@jmeter.apache.org>; Michael Sobczak <ms...@yahoo.com> 
Sent: Wednesday, February 6, 2013 2:05 PM
Subject: Re: Accessing prev object as a DOM
 
On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> Hi,
>
> The API documentation states that there is an object called "prev" that I can access in a BSF Post Processor script.
>
> What I'd like to do is use a BSF Post Processor to create a jMeter parameter based on the value of a field in the response.  If the field is empty, I need to assign a default value to the parameter.  If the field is not empty, I can save the field value in the parameter.
>
> I'd like to use JavaScript in my BSF Post Processor.  How do I reference the document (or DOM) contained within the "prev" object?
>

The prev field is an instance of SampleResult [1] and so you can
access any of its public methods.

However, the Regulal Expression Extractor [2] is likely to be easier to use.
Or perhaps the CSS/JQuery or XPath extractor.

[1] http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
[2] http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> Thanks,
>
> - Mike.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org

Re: Accessing prev object as a DOM

Posted by sebb <se...@gmail.com>.
On 6 February 2013 14:45, Michael Sobczak <ms...@yahoo.com> wrote:
> Hi,
>
> The API documentation states that there is an object called "prev" that I can access in a BSF Post Processor script.
>
> What I'd like to do is use a BSF Post Processor to create a jMeter parameter based on the value of a field in the response.  If the field is empty, I need to assign a default value to the parameter.  If the field is not empty, I can save the field value in the parameter.
>
> I'd like to use JavaScript in my BSF Post Processor.  How do I reference the document (or DOM) contained within the "prev" object?
>

The prev field is an instance of SampleResult [1] and so you can
access any of its public methods.

However, the Regulal Expression Extractor [2] is likely to be easier to use.
Or perhaps the CSS/JQuery or XPath extractor.

[1] http://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html
[2] http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor
> Thanks,
>
> - Mike.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org