JMeter not accepting Valid Regex, causing nothing to be posted



  • I'd like to prefix this question with the fact that i'm a novice when it comes to Jmeter and Regex.

    I have created a test plan for an ASP .Net application, which consists of a GET request, with a Regular expression extractor to grab a token, then a POST request, with a RegEx User Parameter to take the extracted token and use it in the request:

    enter image description here

    In the get request's respnse, there is a value of __RequestVerificationToken, which i am capturing with the following Regex (tested in tree Listner and is Validated):

    (?<=Set-Cookie: __RequestVerificationToken=).{108}
    

    So, it looks for "__RequestVerificationToken=" then gets the 108 characters after it.

    enter image description here

    Regular expression extractor:

    enter image description here

    Parameters in POST Request:

    enter image description here

    The RegEx user parameter i'm using is:

    enter image description here

    But when i run the test, the request post data returns:

    enter image description here

    I've used https://www.regextester.com/ for testing my RegEx and it correctly gets the token, so i'm wondering if JMeter just doesn't accept this?

    Note: apologies for using images rather than text, i couldn't think of a good way to show the data.



  • It looks like your __RequestVerificationToken comes as a HTTP Cookie hence it makes sense to use HTTP Cookie Manager

    1. Add the next line to user.properties file (lives in "bin" folder of your JMeter installation)

      CookieManager.save.cookies=true
      
    2. Add HTTP Cookie Manager to your Test Plan
    3. That's it, now you can access the token value as ${COOKIE____RequestVerificationToken} where required

    Check out HTTP Cookie Manager Advanced Usage - A Guide article for more information


Log in to reply
 

Suggested Topics