jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Speteanu <asp.ad...@gmail.com>
Subject Re: Ajax
Date Thu, 02 Aug 2012 07:45:06 GMT
1) Why would you want to do that? JMeter was not meant to test client side
logic, but to load test the web-server. For this, all you need is replicate
the http requests made to the server, not the entire client-side
behaviour!! This is my advise to you. Analyze the requests made when making
a simple search with auto-complete on and repeat that same type of traffic
with jmeter this time. For the server is practically the same if all is
done correctly.

That's the correct answer you need to listen. Now, to answer the actual
question:

${__javaScript(...)}

http://jmeter.apache.org/usermanual/component_reference.html#BSF_Sampler

This is how you run javascript in jmeter.

2) or the second 1)
vars.get();
vars.put();
are jmeter methods that allows you access to jmeter's variables. Google it
for more details, I use them with beanshell sampler/pre-processor or
post-processor. Nothing else comes to mind fast.

3) or the actual 2)
Export it to jmeter's variables. See above.

But again, the behaviour of the auto-complete is pretty obvious and should
be easy to replicate with jmeter. If you actual plan to use the
autocomplete javascript you will actually need user input during the test.
I doubt that's what you need.

--Adrian S

On Thu, Aug 2, 2012 at 9:42 AM, madhu sekhar <madhuvchandana@gmail.com>wrote:

> Explained the issue little more:
>
> Working on Autocomplete Jmeter Testing task with Jmeter 2.5.1
>
> Problem:
>
> Internally the Autocomplete process is handling by Javascript Function with
> some ajax calls.
> This JavaScript function accepts 2 parameters
> a)  form Name
> b)  url with some paramets & sid
>
> Here is the JavaScript Function code and this will be included under the
> script tag as metnioned below
>
> http://xxxxxxxx:xxxx/current/javascript/components/AC/AutoComplete.js
>
> Her is the content of AutoComplete.js
> ==============================
> // the initial function that gets called in the body onload to enable AC
> function enableAutoComplete(formName, acUrl) {
>     $('form[name="' + formName + '"]
> input:text').live('keyup.autocomplete', function(){
>         $(this).autocomplete({
>             source: function( request, response ) {
>                 $.ajax({
>                     url: acUrl,
>                     dataType: "json",
>                     data: {
>                         style: "full",
>                         maxRows: 10,
>                         term: request.term
>                     },
>                     success: function( data ) {
>                         response(
>                                 $.map( data,
>                                         function( count, key ) {
>                                             return {
>                                                 label: key,
>                                                 value: key
>                                             }
>                                         }
>                                 )
>                         );
>                     },
>                     error: function() {
>                         //TODO: add log
>                     }
>                 });
>             },
>             minLength: 3,
>             open: function() {
>                 $( this ).removeClass( "ui-corner-all" ).addClass(
> "ui-corner-top" );
>             },
>             close: function() {
>                 $( this ).removeClass( "ui-corner-top" ).addClass(
> "ui-corner-all" );
>             }
>         });
>     });
> }
> ==============================
> My Question are
>
> 1. Is it possible to call entire Javascript function in Jmeter? if yes How
> to acheive this?
>
> 1. How to pass 2 parametes to the Javascript function using Post Processor
> or pre processor?
>
> 2. How to use the return value of Javascript function as paramer for html
> request?
>
> On Wed, Aug 1, 2012 at 6:30 PM, Adrian Speteanu <asp.adieu@gmail.com>
> wrote:
>
> > I would use the beanshell pre-processor. BS / BSF allows you to enter a
> > code snippet, java being my choice. So you use vars.get(); and
> vars.put();
> > methods to get and update jmeter runtime variables. In the beanshell you
> > use whatever code logic you need in order to extend the functionality of
> > your test plan (which, with normal jmeter GUI elements is somewhat
> > limited).
> >
> > I only use it when there is no alternative using default elements from
> > jmeter or when I need some functionality available in a larger library, a
> > .jar that is placed in jmeter's lib folder.
> >
> > Look it up in jmeter's manual, maybe you find something that relates to
> > you.
> >
> > The purpose is to have something that allows you to replicate ajax
> > processing, which is client side. Keep it to a must-have basis though,
> most
> > requests can be replicated without duplicating client side logic.
> >
> > --Adrian S
> >
> > On Wed, Aug 1, 2012 at 3:48 PM, madhu sekhar <madhuvchandana@gmail.com
> > >wrote:
> >
> > > Could you please explain me how BSF pre processor works in deeply?
> > >
> > > How to give function(syntax) at parameter value.
> > >
> > > On Wed, Aug 1, 2012 at 6:10 PM, Adrian Speteanu <asp.adieu@gmail.com>
> > > wrote:
> > >
> > > > Well, you'll still need to make http request for each ajax call made
> in
> > > > real application.
> > > > So create 1 http sampler that makes a correct request and in query
> > > > parameter, use a variable.
> > > > Add a beanshell preprocessor in order to gradually increment the
> value
> > of
> > > > the variable (for "smith" it will be s on first run, sm on second
> run,
> > > smi
> > > > on third run and so on). Now how to approach this is up to you. I
> would
> > > > define the search term in a User Defined Variable and in the
> > > pre-processor
> > > > I would brake the word in its characters and gradually create a new
> > > string
> > > > with as many characters as needed. This allows you to enter a
> different
> > > > word without changing the http sampler or the pre-processor.
> > > >
> > > > Does this relate to what you have in mind? (frankly, i'm not sure I
> > > > understood perfectly what is not working for you...)
> > > >
> > > > It should work with a value previously extracted (and dynamic) which
> is
> > > > passed to the sampler's pre-processor.
> > > >
> > > > --Adrian S
> > > >
> > > > On Wed, Aug 1, 2012 at 3:22 PM, madhu sekhar <
> madhuvchandana@gmail.com
> > > > >wrote:
> > > >
> > > > > We need to make dynamic *auto complete* step in a test.
> > > > >
> > > > > We have the the parameter as *term=smith* at sampler of the same
> step
> > > of
> > > > > test .
> > > > >
> > > > > We need make the term as dynamic. I tired using post processor
> > (regular
> > > > exp
> > > > > extractor), But in HTML content we are not founded the parameter
in
> > > > related
> > > > > URL.
> > > > >
> > > > > But we got the same in JavaScript of autocomplete method.
> > > > >
> > > > > Could anybody please suggest me, How to proceed further to make it
> as
> > > > > dynamic.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > madhu kk
> > >
> >
>
>
>
> --
> madhu kk
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message