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.

    <li class="tab">
        <table id="tab2" class="tabTable tabTableSelected" cellpadding="0" onmousedown="tab.Console.openView('tab2', 'NONE', 'NONE', true, false, '');">
                <td class="tabLeft">&nbsp;</td>
                <td class="tabCenter">
                    <span class="tabIconSpan"><img class="primaryTabIcon" src="/test/css/icons_24/Window View Large Icons.png"></span>
                    <span id="tab2Label" class="tabLabel">Dashboard</span>
                <td class="tabRight">&nbsp;</td>
        <div id="tab2-WidgetList" class="tabMenu">
                <span componentId="1234" componentType="portlet.application.widgets.monitorproxy" iconSource="/tabTest/css/icons_16/User1.png">Test1</span>
                <span componentId="9876" componentType="portlet.application.widgets.monitorproxy" iconSource="/tabTest/css/icons_16/User2.png">Test2</span>

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

  • why don't you just use div#tab2-WidgetList span[iconSource ="/tabTest/css/icons_16/User2.png"]?
    – cakes88
    Jun 14, 2016 at 16:42

1 Answer 1


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

The relevant XPath query will be something like:


Reference material:

  • thanks for pointing me in the right direction. XPath allowed me to get the value I was looking for with minimal hoops to jump through. What I ended up with was //div/span[text()='Test1']/@*[3]. Not sure why, but I wasn't able to extract the attributes by name.
    – Jon Foley
    Jun 15, 2016 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.