S
S
sprofxx2020-01-08 05:12:54
Node.js
sprofxx, 2020-01-08 05:12:54

NodeJS Nightmare How to set cookies before visiting the site?

There is code from the Nightmare module example that shows how to set cookies for a site:

nightmare
  .goto('http://google.com')
  .cookies.set({
    name: 'token',
    value: 'some token',
    path: '/query',
    secure: true
  })
  // ... other actions ...
  .then(() => {
    // ...
  })

I need to pick up a cookie saved earlier when visiting the site, for example, when I logged in in another browser instance. And here it turns out that I must first go to the site, then read the old cookies and set them, but the site has already set its new ones! How to set previously saved cookies in Nightmare, no way? All examples from Google are not working, maybe someone has a working example?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question