jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Luu <manga...@gmail.com>
Subject Re: Plan to use XPath Extractor to extract multiple matches but get single match only during execution?
Date Tue, 25 Oct 2011 23:11:15 GMT
Sorry, didn't know that. Here's the URL
http://dlshare.s3.amazonaws.com/shoppingCart.txt

On Tue, Oct 25, 2011 at 3:42 PM, Deepak Shetty <shettyd@gmail.com> wrote:

> hi
> the mailing list rejects attachments. upload it somewhere and send a link
>
> regards
> deepak
>
> On Tue, Oct 25, 2011 at 3:38 PM, David Luu <mangaroo@gmail.com> wrote:
>
> > JMeter v2.5 on Windows
> >
> > Added debug sampler, it did indeed match one only (the first item in
> > shopping list, top down order):
> >
> > ORDERITEMIDS=7249682
> > ORDERITEMIDS_1=7249682
> > ORDERITEMIDS_matchNr=1
> >
> > Attached is HTML from the HTTP sampler response of the shopping cart page
> > for which we extract the data. I did a text search on "removeItemLink"
> and
> > did get 3 entries for the link for 3 cart items.
> >
> > I also did a test replacing XPath extractor with regex extractor and used
> > this pattern to do a global/multi match against:
> >
> > .+class="removeItemLink".+id="(\d+)".+
> >
> > granted if the HTML attribute order ever changed, it would break the
> regex
> > but wouldn't break XPath.
> >
> > In the replacement, I left everything else intact, and used same variable
> > name for the cart items IDs. The regex version worked fine, getting all 3
> > cart items.
> >
> > So there's no loop problem for sure. Seems to be an XPath extractor
> problem
> > here.
> >
> > On Tue, Oct 25, 2011 at 3:16 PM, Deepak Shetty <shettyd@gmail.com>
> wrote:
> >
> >> what version of Jmeter?
> >> Dont go by Firebug it looks at the DOM whereas JMeter will have to look
> at
> >> the source html .
> >>
> >> Add a Debug Sampler under your HTTP Sampler and also add a view results
> >> tree
> >> listener.
> >> If your debug sampler shows your multiple values correctly the problem
> is
> >> in
> >> the loop
> >>
> >> If your debug sampler only shows a single value , then you need to look
> at
> >> the HTML response (in view results tree listener) that your xpath
> >> extractor
> >> is a child of and see if you have multiple nodes satisfying your
> condition
> >> or your HTML is different from what you expect.
> >> If the HTML looks right , then upload a copy of the html and send the
> link
> >>
> >> regards
> >> deepak
> >>
> >> On Tue, Oct 25, 2011 at 1:27 PM, David Luu <mangaroo@gmail.com> wrote:
> >>
> >> > Hi, just wanted to check to see if I misconfigured something or XPath
> >> > defined correctly. Here's the setup:
> >> >
> >> > We have HTTP request sampler to hit user's shopping cart that returns
> >> HTML
> >> > in response. The HTML is dynamic based on what user already has in
> cart.
> >> >
> >> > I want the JMeter test to remove items in cart, and we do that by
> >> fetching
> >> > the item ID stored in the links to then remove item by make HTTP POST
> in
> >> > another sampler with the item ID. The XPath is as follows:
> >> >
> >> > //a[@class='removeItemLink']/@id
> >> >
> >> > We identify the item ID as an attribute in links with class type
> >> > 'removeItemLink'. Unfortunately, or to play it safe, we don't know if
> >> the
> >> > generated HTML always has same fixed pattern text of whether the class
> >> > attribute is always before or after the ID attribute, hence I chose to
> >> use
> >> > XPath extractor rather than a regular expression extractor to get the
> >> ID.
> >> > ID
> >> > value is also dynamic and may not be fixed length.
> >> >
> >> > I enabled Tidy with quiet mode. Later also enabled report errors show
> >> > warnings, and disabled quiet mode, those options didn't help. The UI
> and
> >> > the
> >> > docs don't mention anything about settings to match once or match all,
> >> etc.
> >> > So believe matching number determined by the XPath expression.
> >> >
> >> > used XPath extracted variable reference name ORDERITEMIDS
> >> >
> >> > and then had a ForEach controller run a HTTP request sampler to POST
> to
> >> API
> >> > to remove items. But during execution, it only ran once, but it did
> work
> >> > correctly for the one item that it extracted. ForEach controller
> >> configured
> >> > as follows:
> >> >
> >> > input var prefix = ORDERITEMIDS
> >> > output var name = returnVar
> >> > checked add "_" before number
> >> >
> >> > and in HTTP sampler inside the foreach, reference variable as
> >> ${returnVar}
> >> >
> >> > I tested the XPath with Firebug in Firefox and it matched all the
> items
> >> in
> >> > the cart unlike JMeter, and I know the basics of XPath, and that
> appears
> >> to
> >> > be the correct XPath.
> >> >
> >> > So is this a bug with JMeter or am I doing something wrong? Or wrong
> >> XPath
> >> > somehow still?
> >> >
> >> > Regards,
> >> > David
> >> >
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
>

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