How extract cookies for subsequent connection test #2841
Replies: 5 comments
-
Hi! You can access the CookieJar for the Session at |
Beta Was this translation helpful? Give feedback.
-
I had follow your advise to use the cookies in login request but how to use the cookie in subsequent after login request. Below is my code:
Please help as i new to python. |
Beta Was this translation helpful? Give feedback.
-
Ah. To reuse cookies as a normal browser does, you shouldnt need to do anything at all, I thought you were trying to do something more advanced. Check the response from the POST that does the login to confirm that it actually worked and contains the headers to set the cookie. This might be helpful: https://docs.locust.io/en/stable/running-in-debugger.html#print-http-communication |
Beta Was this translation helpful? Give feedback.
-
I want to use the cookies in the following request(Check Account and order history function). How to do it? Below is my code:
The check account and order history function need login before can fire the request. How to use the cookies in these function? |
Beta Was this translation helpful? Give feedback.
-
Like I said, you don't need to do anything at all to persist cookies. However, in your locustfile, there is nothing to ensure login happens before your other requests. To fix that, either put all your requests in a single task with the login-POST first, or define an on_start method where you do the login, see documentation. If that doesn't help, you need check the debug log from actually running the test and examine the response from the login request. |
Beta Was this translation helpful? Give feedback.
-
Dear forumers, I have a login request which the response assign to response variable as global scope. How to extract the token or something from the request??
Beta Was this translation helpful? Give feedback.
All reactions