Jmeter testing for Login

2019-07-27 23:09发布

问题:

I have to test a web-app for login using Jmeter.

How is that done?

Should I give the path of the login page in the HTTP Request sampler and add the username and password to the login config element?

回答1:

It needs to be realistic hence your test should be designed as follows:

  1. HTTP GET Request (simulate opening Login page with a browser)
    • Post Processor to fetch dynamic parameters values (if any)
  2. HTTP POST Request (login event itself) where you pass your credentials and dynamic parameters
    • (optional) Response Assertion to verify that user is really logged i

I would also recommend adding HTTP Cookie Manager to represent browser cookies and deal with cookie-based authentication.

See How To Use JMeter For Login Authentication guide for step-by-step overview and demo