How to handle the logout process in jmeter? - jmeter

I am using j meter to run the concurrent users.After login the application, I searched the files and finally logout from the application.I don't know to handle the logout process.Currently I created the 100 users.
100 users are logged into the application.
100 users are searched something.
100 users are needed to sign out.
How to do the third step. When I was recording the logout,there is no process are recorded.Could you please tell me the solution.

Usually logout is:
Associated with the relevant HTTP Request
Assumes clearing session data so if you have > 1 Loop on Thread Group level and using one of the following (or both):
HTTP Authorization Manager
HTTP Cookie Manager
Make sure you have Clear xxx on each iteration box checked

Logging out is a call just like any other- and it will be specific to your site. If you closed a browser tab or window, it's possible that you didn't actually log out from your site. It's also possible if you stopped recording too soon that you simply didn't record it.
I suggest manually adding it. You'll have to go into your Browser's Network Debugger to find the actual call that you're looking for, and then recreate it in JMeter.

Related

Is Cypress compatible with Salesforce?

After I log in, the domain changes and it doesn't do anything else that my script tells it to do. Is it the case that you just can't do anything once the domain changes? I can't quite tell from the documentation. I know it says that it can't navigate to a second domain, but I haven't seen where it says it can't do anything on a second domain.
Additionally, did Cypress used to login to Salesforce with cy.request()? Because currently Salesforce doesn't allow for logging in by sending a request with parameters.
cy.visit('https://test.salesforce.com');
cy.get('.username').type(username)
cy.get('.password').type(password)
cy.get('#Login').click()
This is my code for logging in.
Hi you can use Session in cypress in order to Cache and restore cookies, localStorage, and sessionStorage
Just create a command in ./support/command.js
You can read the documentation here https://docs.cypress.io/api/commands/session#Syntax

Partial Logout of some users in JMeter

I have this workflow
Login (Once)
Create Orders (in a loop for x mins)
Logout (Once)
Please let me know how can I achieve the below workload in JMeter:
Log in all the users -group 1- (say 10 users ). Keep on creating Orders.
Log in another set of users -group 2- (say 10 users, after 15 mins of the test). Keep on creating orders.
Log out all group 1, [Lets say after 45 mins of the test].
Logout group 2 [At the end of the test, let's say after 1 hr.]
Note: Main focus of the test is to logout the first 10 users and keep the next 10 users running till the end of test.
Edit 1: Removed "Stay Logged in" to avoid confusion. Threads should keep on creating orders until they log out.
What do you mean by "stay logged in"? If user doesn't send any HTTP requests to the server it doesn't produce any load so it doesn't make any sense to "stay logged in" unless it is connected with some network footprint which you need to mimic.
Most probably when you log into the application you're getting a Cookie which has Expires attribute so when you make the next request it checks whether your session is expired and if it's not - you're still "logged in", if it is - you will be redirected to the login page.
If you still want to implement your weird use case you can add a Constant Timer as a child of the Logout request and configure the "sleep" time there.
If there is some background network activity (like some information on the page is refreshed by AJAX requests) the users will need to send these requests periodically and in this case you also need to introduce timers as real users don't hammer application non-stop, they at least need some time to "think" between operations or to simulate periodic polling if they're "idle"
More information: A Comprehensive Guide to Using JMeter Timers

session handling in struts 2

I am stuck with a session handling problem for past few days.
I am working on an application where an user logs into his account and can register there details or change them. How to manage sessions in this case. I mean how can i access the attribute of a session in different action classes?
Also when i click on log out and after that i press the back button given in the browser it goes back to the previous page and user can change their details which should not happen. Please help !!
The back button "issue" is because you have not disabled page caching.
Sessions data is available in actions via the SessionAware interface.
Sessions are per-user (more or less, actually per-conversation, and how that's implemented varies somewhat across browser versions), not sure what you mean regarding concurrent users.

Handling multiple sessions for same user credentials and avoiding new browser window opening in my web application

I want to handle following scenarios in my new web application.
If multiple users log into the application with same credentials, the application should deny access.
Since I have out of process session store, I would be able to make out when this situation happens. So I can deny all requests after first successful attempt. This will however not work if the user instead of logging out of the application, closes the browser. The session will continue to reflect in the store for the period of timeout value.
If a user attempts to open a new browser windows (Ctrl+N), the application should defeat this attempt. Every new page can potentially fiddle with cookies. I want to therefore deny the users the ability to open new window.
How about?
Having a server timer and then track users session. Reset the timer when you get the request back to the server.
Not possible. Ctrl + N is for opening a new browser window and this does not mean that the user is going to visit your site.
Also check out this question which might be of some interest.
How to differ sessions in browser-tabs?

Firefox extension to log out user after the page has been closed

I am writing my first FireFox extension and I have some questions. Maybe someone can help.
I have a website which requires login. The sign-in is one user per login type. So if I am logged with the username "tom" from one PC and go to other PC and try to login with the same details, it fails. When I click the log-out button from my authenticated page, the new location executes a PHP function to log-out the user (updates the "logged" status of the user in MySQL). The problem is that if a user is logged in from his work desk and surfing the page then suddenly he gets a call by a friend to quickly grab lunch in his break and has to meet him in short time, he just clicks the X (close) button from Firefox, forgetting to press the log-out button so the status of the logged is still 1. Later on, if he wants to access the page again from home, he won't be able to log in.
So, I need to grab the "close" event from firefox somehow. I am thinking about looking for the ones that contain the "website.com" domain only. Then, if a tab is closed or the main window of Firefox is closed, send an unique key, and the username to that URL that logs out the user and the problem may be solved. I don't know if this is possible. Please post any idea (followed by code if you can) for this extension to be built.
Thank you.
By design, this is wrong.
If a user's PC crashes (harddisk failure, power failure) your plugin won't be able to log out the user. And so, the user won't be able to login on any PC.
--
Let's revisit the premise,
a. why does logging in from another PC need to fail?
b. How about invalidating the login from the previous PC (log out) when the user logs in to another PC. THis is kind of like how chat applications like Yahoo! Messenger work.
From your answers, here's what i would suggest: if the user is logged in on another PC, warn and present the user with options:
cancel logging in
forcibly log out the other user and proceed to logging in
Logging the user out after a certain time of inactivity is the (application or web) server's responsibility, not (only) the client-browser's. This is called a session timeout.
You might be able to avoid the timeout by a browser implementation as you describe it, but this should not be the primary solution.
Here's an off hand approach you might take:
In your case I would include a timestamp in the table where the 'locked' state is stored. Every time a user does an action that timestamp is updated. When you try to login again ad the timestamp is older that a certain threshold (e.g. 15min) your login code should silently logout the previous user.
In order to receive a notice about the tab being closed, you'll want to do something like this sample code. However, instead of listening for load, you'll want to listen for unload.
When you do end up getting notified about unload, you'll have to do a request to the logout page just like the web application does. You can figure out what the location of the document that is unloading is by checking aEvent.originalTarget.location.href. Note that aEvent.originalTarget will give you the document object of the tab that is closing. You'll then want to use an XLMHttpRequest for this in your event handler.
You could use ajax that would ping a page on the site - all the session info will be passed and you can verify that the user still has an active browser/page open. If Firefox crashes it won't be able to ping the website anymore and the session could time-out after 15 minutes. I think that allowing a forced logout on another sign-in would be best. Usually when I leave work at the end of the day I wouldn't close all the programs or logout or anything - just lock my computer to prevent anyone from using it. Next morning I come back with all my programs still running so I can continue where I left off.
BTW, Yahoo Web messenger probably uses some form of session-based cookies. That is, cookies are stored in memory and are gone when the tab or browser are closed.
Just enable to the user to re-login from another machine. And if you get a request from the user on first machine, ask him to re-login too. So you get a single logged in user at a time.

Resources