Redirect Jmeter to the home page after successful login with multiple users - jmeter

I created a script multiple user logins and redirected to the home page. For multiple user logins fetching data from CSV file but after logged in, home page redirection is not working.

There are multiple possible explanations:
Your login fails somewhere somehow so you're still at the login page, check the server response using View Results Tree listener and if this is the case - fix your script. It might be sufficient to add a HTTP Cookie Manager to represent user session
You might need to play with Redirect automatically / Follow redirects checkboxes on HTTP Request sampler level
Your redirect is being managed by JavaScript and JMeter is not capable of executing JavaScript so you need to extract the desired redirect location using a suitable JMeter Post-Processor (basically implement correlation of the redirect URL) and add another HTTP Request sampler to open the redirect target.
More information: Redirections in HTTP
In general make sure that JMeter sends the same requests as the real browser does, given this simple rule is met you should be able to properly simulate real user actions

Related

Golang - Server Side Login Handling - how to resume request after login?

Currently, I’m developing a web app with server-side rendering using the Gin framework and I’m having a problem with login intercepting. When an HTTP GET request hits an endpoint, middleware is used to check the browser cookie and redirect the traffic to the login page. This works fine and after successful login, the user is always redirected to the dashboard page. My question is how I should redirect the user back to the originally requested URI instead of the dashboard page?
Also, a bit more complex scenario is on HTTP POST. It looks like the HTTP POST method doesn’t work quite well with a redirect. Also, how would I resume the request with the same post request after the user successfully login?
Thanks for the help!
For the HTTP GET scenario, this one is easy, you need to remember the original URL somewhere. The are a few ways you could go about this:
Store the URL in session information(if any is available, you do need sessions for non-authenticated users)
Store it in a query string, for example, redirect to example.com/login?original=https%3A%2F%2Fexample.com%2Fanother-page. Your login page can look for the query parameter and include it in the login form or make sure that the action of the login form matches the given URI. On a successful login attempt you can get the original URL form the query param and set it as the Location.
Store the original URL in a cookie, upon successful login you can just check the cookie value and use that.
As for the HTTP POST scenario. If you just want to redirect the same POST request to a different URL you can use a 307 Temporary redirect. A 307 will preserve the request body and method and not turn it into a GET request like a 303 See Other or 302 Found.
Resuming the original POST after showing the login screen and after a successful login is a little more complex. When you redirect to the login page you interrupt the flow of the user, maybe it is better to let the user re-post their request after logging in, instead of doing it for them.
Having said that, it is technically possible. We require two steps, first is storing all the data to recreate the request. Then after login completion we can render a form with this saved data and use javascript to submit the form. By adding:
<script>document.getElementById("myForm").submit();</script>
After your form, the browser will submit the form after loading the javascript, thus recreating the original POST.
The storage part can be done via the server side session or a cookie.

Login page is returned always even though sessions are handled

JMeter version 5.x and 4.0
Protocol : Https
Steps
Start creating a test plan with a recording template
Configure the HTTP(S) Test Script Recorder with HTTPS domain, target controller
Save the test plan and start the proxy server
Configure Firefox with security certificate and proxy details
Access the login page https://www.systemname.com . Request is recorded
Login to the system with valid credentials. Request is recorded successfully
Add a Boundary value Extractor post processor to extract session variable (LCSRF_VAL) and replace the session value recorded in the login request with ${LCSRF_VAL}
Save the test plan and run the test
Check the responses in View Result Tree --> HTML view
Actual Outcome
User is not logged into the system. Login page is returned.
Expected Outcome
User should be able to login when sessions are handled
Note :
It worked fine if recording started from a URL of a page inside the system. For example
https://www.system.com/en/administration/Search?nav=Administration

Make a request handle redirect by providing necessary parameters

I'm using jmeter to load test a Feature Page.
My jmeter requests (for that page) are being redirected to a login page. How do I provide login info for that redirect?
I already tried:
Controller
Login Page
Feature Page
Logout
But somehow a user even though already authenticated via Login Page is still being asked to login on the Feature Page.
Wondering if someone has a suggestion.
Make sure you're really logged in as "green" result in JMeter doesn't necessarily indicates successful request. You can verify responses using View Results Tree
listener
Add HTTP Cookie Manager to your Test Plan, if your application uses cookies for establishing/maintaining user session it should automatically resolve your problem
Inspect your test plan for any dynamic values (request parameters, headers, URL postfixes, etc.), if the are - they need to be correlated.

multiply login request in JMeter

I use JMeter to load data using web services. I need to login from JMeter once, then I need to read ids from CSV file and call HTTP request for each id.
My current configuration is as in the attached picture.
The problem is that in this case login is called for each HTTP Request. I want to change it, so it will be called only once at the beginning. What is the best way to do it in JMeter?
Right click on login -> Insert Parent -> Logic Controller -> Once Only Controller:
The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.
..
For testing that requires a login, consider placing the login request in this controller since each thread only needs to login once to establish a session.

How to Configure Jmeter for after Login process in an Application?

How to Configure Jmeter for after Login process in an Application?
I am able to configure the login request for 100 users from the CSV file with the help of Jmeter's "CSV Data set Config", but after the successful login of all I want to know how to configure the jmeter to go to the "Offers" page of there(100 user) accounts.Means 1 User can login & View his/her "Offer" page.Please Help.
There are two ways to achieve this scenario:
add another HTTP sampler & fill the details like Server IP, Path of Offers URL (you will have already done the same for Login), HTTP Header data etc. and pass correlation parameters from the response of Login if required to view the offers specific to 1 user.
make sure you use right method (GET/POST) in HTTP Sampler.
record the whole scenario (ref: http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf).
You will still have to do the correlation of parameters (using regular expression extractor or Xpath extractor) wherever required. This entirely depends on the parameters required for the offer page HTTP request.
hope this will help.
You'll need a cookie manager to store the session and cookie for all logged in users.
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager

Resources