skip to Main Content

I am creating a JMeter Script to add products into the cart for the Magento2 website. Post request is executing without any error but the product isn’t displaying into cart after that request.

Check snap of post request

2

Answers


  1. JMeter automatically treats HTTP responses with status codes below 400 as successful, it doesn’t know anything about Magento or product adding to cart. If you need to introduce an extra check that the product is there – you need to add Response Assertion

    In the absolute majority of cases the main reason for “failing” requests is missing or not properly implemented correlation of the dynamic parameters:

    1. Check that your ${form_key} JMeter Variable has anticipated value using Debug Sampler
    2. Your request URL looks very suspicious, it might be the case you need to extract the URL for adding this particular product from the previous response as well
    3. Don’t forget to add HTTP Cookie Manager to your Test Plan

    Also be aware that there is a Magento performance-toolkit containing benchmark.jmx script which you can use as the reference/basis for your own tests

    Login or Signup to reply.
  2. You likely need to handle the dynamic values associated with cart identifier with the session. I will save you some time however, architecturally when Magento issues the cart is a known antipattern – every time I see Magento it is a default cart model.

    What does this mean, the “default cart…?” This is a pattern of too early allocation of a resource. Twenty percent or fewer of visitors will ever use the cart, yet 100% of the population are allocated carts. You now have cart objects and cart resources which are dead resource allocations in the system that have to be managed, which includes clean up after a period of time/time out.

    The performant design pattern is a just-in-time cart which is only created when the use either adds something to the cart or selects the cart icon to view the contents of a stored cart. Going along with this, the number of items in a perpetual cart should be persisted in a local cookie value rather than require a “pull” of the cart every time the user visits the site.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search