From JMeter project main page
JMeter is not a browser. 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 viewed at a time).
Although JMeter cannot execute JavaScript, it is capable of recording associated HTTP Requests.
In case of simulating a login with JMeter it might be the case when some dynamic token is being generated with JavaScript so you need to extract it from the 1st response source code and add as a parameter to 2nd request so your test should look like:
- GET request to login page
- POST request to login page (pass dynamic parameter(s) extracted in previous step along with the credentials)
See How To Use JMeter For Login Authentication for detailed step-by-step instructions.
Retrieve all embedded resources from HTML files
". This will ensure that images, JS files, CSS files, etc. are retrieved from the server. – Adnan