0

In order to generate HTTP requests to open a particular window, I need to obtain the component ID which is nested as an argument in onmousedown="Console.openView()" - in this example componentId= 1325.

<tr>
    <td id="primaryTab6-primaryMenuTab1" class="primaryMenuTab" onmousedown="Console.openView('primaryTab6-primaryMenuTab1', 'portlet.app.tc.management', '1325', false, false, '');" 
                                    onmouseover="Console.hoverMenuItem(this, true);" onmouseout="Console.hoverMenuItem(this, false);">
        <img class="primaryMenuTabIcon" src="/v/css/icons_16/Scale.png">
        <span id="primaryTab6-primaryMenuTab1Label" class="primaryMenuTabLabel">Accounting</span>
    </td>
</tr>

My XPath currently looks like this:

//div/table/tr/td[contains(span,'Accounting')]/onmousedown="Console.openView(@*[3])"

But this only returns the with the final argument of 'false' - no matter what I enter for the match position, it returns the same thing.

I've attempted to tokenize:

//div/table/tr/td[contains(span,'Accounting')]/tokenize(@onmousedown="Console.openView"",")[3]

However this returns:

TransformerException: Unknown nodetype: tokenize

I originally was trying to use Regular Expression extractor, but that provided it's own set of difficulties.

  • Have you thought of executing a javascript call to interact with the control and then pulling it? I'm guessing you want to get the value after interaction? – mutt Mar 10 '17 at 20:08
  • @mutt that's the next stop on this rabbit hole, learning how to do it via javascript. Trying to pull the ID in a post-processor on when the page loads the menus for use later in the test plan. – Jon Foley Mar 10 '17 at 21:20
1
  1. There is no tokenize function in XPath 1.0 therefore you won't be able to use it.
  2. The = operator in XPath compares 2 nodes therefore you will always be getting false as left side of expression will never be equal to the right side

I would recommend extracting this 1325 value in 2 steps:

  1. Extract the whole onmousedown attribute using the following XPath query:

    //td[contains(span,'Accounting')]/@onmousedown
    

    XPath Extractor

  2. Extract 1325 value using Regular Expression Extractor like

    '(\d+)'
    

    JMeter REgular Expression

  • Thanks @Dmitiri - running reg ex on the XPath extracted variable works. Will have to investigate a more efficient way of pulling out all the needed componentIds in the future. – Jon Foley Mar 14 '17 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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