mucsi96 / nightwatch-api

[DEPRECATED] Cross-runner API for Nightwatch.js
https://nightwatch-api.netlify.com/
MIT License
84 stars 64 forks source link

New instance of Chrome browser in incognito mode still remembers HttpOnly cookies #811

Closed Qvatra closed 5 years ago

Qvatra commented 5 years ago

On my website I started to use HttpOnly cookies for session persistence after refresh.

The problem is that tests are started to fail simply because after first login browser still sees cookie and login steps for the next test fail.

Nightwatch api provides deleteCookies method but it can not delete HttpOnly cookies.

I tried to configure chrome to run in incognito mode but it still remembers the cookie during test run. When I was testing manually in incognito mode it was working ok as long as i close browser after each test, so my assumption is that Nightwatch doesn't actually closes the browser instance and as a result browser remembers cookie.

is this can be considered a bug or I'm missing something? Thank you in advance.

Qvatra commented 5 years ago

I found a way but not sure that this is the right way as session would be reset for each test:

does session == browser instance in this case?

also now Im wondering do other browsers have alternative to incognito mode?

const { createSession, closeSession } = require('nightwatch-api')
const nightwatchConfigPath = 'e2e/nightwatch.conf.js'

Before(async () => {
  await createSession({
    configFile: nightwatchConfigPath
  })
})

After(async ({ result: { status } }) => {
  await closeSession()
})
Qvatra commented 5 years ago

update: noticed that test are working even without 'incognito' setting for browser using new session for each test

spnraju commented 5 years ago

Hello @Qvatra , thank you for bringing this to our notice. I am afraid this is not an issue with nightwatch-api. but with nightwatchjs https://nightwatchjs.org/api/commands/#deleteCookies. Please report it here