I am testing website deployed based on Magenta Template Framework, the problem that occurred is that the cart kept being empty even the add to cart link has been ran. And furthermore, i kept getting the error "invalid form key please refresh key".

Variable that has been extarcted, PHPSESID, Formkey and coded using cookie manager. Here is the extracted key

The error is still occuring. This is the error i kept getting


Most probably your JMeter script doesn't provide correct form_key parameter, it is being used by Magento for protection from CSRF attacks so you need to

  1. Extract this form_key value from the previous response and save it into a JMeter Variable
  2. Replace previous (recorded/hard-coded) value with the variable from the step 1

Here how it looks like at i.e. Magento Online Demo instance:

enter image description here

and here is how you can extract it using i.e. CSS Selector Extractor

enter image description here

More information: How to Load Test CSRF-Protected Web Sites

  • I have extracted the form key from the main page and insert the form key using the cookie manager. But the error still occured, i have updated my posting with the screenshot. – pseudox Dec 8 '20 at 3:33

Open the console tab in your browser's developer tools and check if a CORS error has occurred. If there is a CORS error, please add the address to the csp white list... This is the most frequent cause in my case.

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.