0

I decided use framework CodeceptJS and library Nightmare.

Mine issue is set cookie before run all test suite I read the documentation and understanding so for that to solve mine issue me need use helper classes. Maybe I'm wrong but still. Perhaps you need to use a different approach if so let me know.

It mine helper

'use strict';

class SetCookie extends Helper {

  constructor(config){
    super(config)
  }

  _beforeSuite() {
    this.client = this.helpers['Nightmare'].browser;

    this.getCookies().then((cookies) => {
      console.log(cookies);
    })
  }

getCookies(){
  return this.client.cookies.get()
  }
}

module.exports = SetCookie;

Problem Cookies return after finished test suite

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Mihail Kuznetsov
  • 323
  • 5
  • 22

2 Answers2

0

https://codecept.io/helpers/Nightmare/#setcookie That is existing nightmare helper. Did you try it?

0

I solved this problem: Mine Helper

    async setSplitCookies() {
        const client = this.helpers['Nightmare'];

        const cookie = {
          name: 'rc_web_spl', 
          value: 'on',
          url: 'http://www.nic.ru'
        }
        return client.setCookie(cookie);
}

Mine test:

Before((I) => {
    I.setSplitCookies();
  });
Mihail Kuznetsov
  • 323
  • 5
  • 22