Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access cookies in Cookiejar #3198

Open
aryalakshmi opened this issue Feb 7, 2024 · 0 comments
Open

Access cookies in Cookiejar #3198

aryalakshmi opened this issue Feb 7, 2024 · 0 comments

Comments

@aryalakshmi
Copy link

aryalakshmi commented Feb 7, 2024

Version and environment information:
-->

  1. Newman Version (can be found via newman -v):6.1.0
  2. OS details (type, version, and architecture): Windows 10
  3. Are you using Newman as a library, or via the CLI? Library
  4. Did you encounter this recently, or has this bug always been there: Always
  5. Expected behaviour: Unable to access cookies obtained from Postman interceptor using Cookiejar
  6. Command / script used to run Newman: node WriteTofile.js (https://gist.github.com/aryalakshmi/4040e68a9b7a6253d467c846ccba9c45)
  7. Sample collection, and auxiliary files (minus the sensitive details):
  8. Screenshots (if applicable):

Steps to reproduce the problem:

  1. Trying to automate all APIs for a router webgui
  2. Fetching 3 cookies using Postman interceptor called cookie1, cookie2 and lang
  3. use cookieJar and access cookies in Tests of Request 1. Set it as a Header. Set cookie as a collectionvariable
  4. Use the cookies in Request2
  5. Run collection from POSTMAN -> Success
  6. Export collection and run using newman library -> Cookiejar unable to fetch the cookies

Codesnippet of Request1:
const cookieJar = pm.cookies.jar();
const url = 'http://192.168.x.1'
cookieJar.getAll(url, (error, cookies) => {
if (error) {
console.error(error);
} else {
console.log(cookies); =>Newman returns this as EMPTY
const cookie1Value = cookies.find(cookie => cookie.name === "cookie1").value;

}
});

May i know if there is any way to access cookies in cookiejar or any other way to access the cookies.
Note: These cookies are not accessible in any API response also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant