Search code examples
cookiesjmeterperformance-testingjmeter-5.0

How to manage Cookies are required error page?


I am new to jmeter. I record my script using blazemeter chrome plugin. Now in login I am getting Cookies are required Cookies are disabled on your browser. please enable cookies and refresh this page I have set CookieManager.save.cookies=true but no luck Please check the image attached.


Solution

  • As per JMeter project main page:

    JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

    So if your page is using JavaScript in order to check user cookies there is no way to bypass this message, it means that you can just ignore it.

    However if you cannot proceed further it means that JMeter doesn't send necessary Cookie header so make sure to add HTTP Cookie Manager to your test plan.

    If you added the HTTP Cookie Manager but still seeing that the real browser sends cookies and JMeter doesn't (or sends partial) most probably it means that your server returns malformed or expired cookies and you need to raise a defect for your application.

    And last but not the least, if you have to live with these malformed/broken cookies and still need to log in you can go for the following workarounds:

    • Change "Implementation" of the HTTP Cookie Manager to something less restrictive, i.e. netscape

      enter image description here

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

       CookieManager.check.cookies=false
      
    • Increase JMeter logging verbosity for the HTTP Cookie Manager by adding the next line to log4j2.xml file:

       <Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
      

      this way you will be able to figure out what's wrong with the cookies

    • And last but not the least you can always manually extract cookies from the Set-Cookie response header using i.e. Regular Expression Extractor and again manually add them to the HTTP Cookie Manager or HTTP Header Manager