How to retrieve value based on Span value in JMeter with JQuery Extractor



  • Trying to retrieve the componentId as a variable from the response below using the CSS/JQuery Extractor in JMeter.

    I'm successfully getting the componentId returned using

    Expression: div#tab2-WidgetList span[componentType="portlet.application.widgets.monitorproxy"]  
    Attribute: componentId
    

    I could specify Match No. = 1 to return the first and Match No. = 2 to return the second, but I want to avoid hard coding it in case the order changes in the future.

    I would like to return the value based off of the span elements of Test1 and Test2.

        
  •   Dashboard  
    Test1 Test2
  • JMeter is still pretty new to me, so I've been having some trouble getting this one down.



  • You cannot select text value using CSS so I would recommend going for XPath Extractor instead.

    The relevant XPath query will be something like:

    //span[text()='Test1']/@componentId
    

    Reference material:


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2