Search code examples
regexjmeterhrefjmeter-plugins

extracting a part of an href in JMeter


i'm stuck with the following. i have a page on ibm filenet containing a list with objects (these are documents or files) which have a specific classID and ID in their href. i need JMeter to get all HREFS containing a specific type of ID:

<a href="http://ipaddress/Workplace/Browse.jsp?eventTarget=WcmController&eventName=GetInfo&id={350B278C-DE7D-44DE-9B54-099672152476}&vsId=&classId={F14AC85A-4474-479A-9B4E-BCBA180B7975}&objectStoreName=Nice&majorVersion=&minorVersion=&versionStatus=&mimeType=&mode=&objectType=customobject&isPopup=true" target="_blank">

the 'classId' = {F14AC85A-4474-479A-9B4E-BCBA180B7975} is the right class id type i need to click on the page (there are several files with this classID but that is no problem). on the other hand the 'id' is thus different for each file.

how can i extract all 'id's containing this specific classId and make JMeter pass it to the next sampler, so it clicks on just one of them? what will my RegEx look like?


Solution

  • As already mentionned in the comment, I do not know jmeter and how to implement it in the code. A regular expression to match both id and classId within a link would be:

    ~(classId=|id=)([^&]*)~g
    

    This is, search for a string classId= or id= first. If one of the strings is found, match any character afterwards, except an ampersand (&), as many times as possible (*) and capture it in a group (brackets). Possibly you need to fiddle with the parameters (e.g. /g for global) after the regex.
    See this regex101 fiddle for more information.