Login doesn’t work and it redirects again to login page in magento 2 using jmeter



  • I am new to JMeter. I tried to record login or sign-up using the JMeter proxy in Magento 2.2.7 and I tried to view the result in the JMeter, but in JMeter. I'm unable to get the response of the login page success. Please find the screenshot:

    enter image description here



  • In the absolute majority of cases you will not be able to successfully replay script recorded by HTTP(S) Test Script Recorder without performing correlation

    Modern web applications widely use dynamic parameters for client-side state tracking or security reasons, in case of Magento most probably your login fails due to form_key parameter incorrect value.

    Also don't forget about Cookies

    The steps would be:

    1. Add HTTP Cookie Manager to your Test Plan
    2. Add HTTP Request sampler to open login page, i.e. make a GET request to /customer/account/login/

      enter image description here

    3. Add a suitable JMeter's Post-Processor to extract the aforementioned form_key field value, I would recommend going for CSS Selector Extractor

      enter image description here

    4. Add another HTTP Request sampler which will perform the actual login, i.e. making a POST request to /customer/account/loginPost Make sure to replace recorded hard-coded value of the form_key parameter with the reference to JMeter Variable from step 3

      enter image description here

    5. That's it, you should be logged in now:

      enter image description here



Suggested Topics

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