【问题标题】:CodeceptJS and Nightmare - set cookie before suite in helper classCodeceptJS 和 Nightmare - 在助手类中的套件之前设置 cookie
【发布时间】:2018-08-26 14:00:58
【问题描述】:

我决定使用框架 CodeceptJS 和库 Nightmare。

我的问题是在运行所有测试套件之前设置 cookie 我阅读了文档和理解,因此为了解决我的问题,我需要使用帮助类。也许我错了,但仍然。 如果是这样,也许你需要使用不同的方法让我知道。

它是我的帮手

'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;

问题 完成测试套件后返回 Cookies

【问题讨论】:

    标签: qa nightmare codeceptjs


    【解决方案1】:

    https://codecept.io/helpers/Nightmare/#setcookie 那是现有的噩梦帮手。你试过了吗?

    【讨论】:

      【解决方案2】:

      我解决了这个问题: 矿工

          async setSplitCookies() {
              const client = this.helpers['Nightmare'];
      
              const cookie = {
                name: 'rc_web_spl', 
                value: 'on',
                url: 'http://www.nic.ru'
              }
              return client.setCookie(cookie);
      }
      

      矿山测试:

      Before((I) => {
          I.setSplitCookies();
        });
      

      【讨论】:

        猜你喜欢
        • 2019-07-19
        • 1970-01-01
        • 1970-01-01
        • 2019-12-09
        • 2020-02-10
        • 2023-01-14
        • 2017-07-23
        • 2010-11-02
        • 1970-01-01
        相关资源
        最近更新 更多