SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Aug 2006
    Posts
    344
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    XPath extractor only matches once?

    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

  2. #2
    Member
    Join Date
    Aug 2006
    Posts
    344
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XPath extractor only matches once?

    FYI, using 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.

    Or maybe the XPath isn't specific/detailed enough?

  3. #3
    Member
    Join Date
    Jan 2010
    Posts
    94
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XPath extractor only matches once?

    A front-end automation testing tool like Selenium seems more appropriate....

    I think you're only half way in your debugging. Download firebug and set the tab to 'net' traffic. When you're on the page you want Jmeter to send (on the browser), clear your net traffic and invoke the ajax call.

    See if that POST is same/similar to the post Jmeter is sending with your regex'd values.

  4. #4
    Member
    Join Date
    Aug 2006
    Posts
    344
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XPath extractor only matches once?

    Thanks for response.

    Got answer from JMeter mailing list. Turns out the Tidy parser didn't like the HTML from the shopping cart page and only parsed out 1 of the links. Nothing I can really do other than to fall back to regex.

    Selenium would be more appropriate, except in a load test as Selenium even with Grid won't scale as far as using JMeter to do the same test. The test discussed here is for a load test.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:10 PM.

Copyright BetaSoft Inc.