【问题标题】:how can i run all webdriver.io spec files in single browser session?如何在单个浏览器会话中运行所有 webdriver.io 规范文件?
【发布时间】:2019-03-17 18:22:13
【问题描述】:

我正在使用 wdio 运行测试。我将 maxInstances 减少到 1。但是 wdio 日志记录表明它会在每个规范文件之前创建一个新会话。如何在单个浏览器会话中运行所有 webdriver.io 规范文件?提前谢谢你。

wdio.conf.js 是:

exports.config = {
  specs: ['./test/specs/**/*.js'],
  maxInstances: 1,
  capabilities: [{
    maxInstances: 1,
    browserName: 'chrome',
  }],
  sync: true,
  logLevel: 'verbose',
  coloredLogs: true,
  screenshotPath: './errorShots/',
  baseUrl: process.env.ROOT_URL,
  waitforTimeout: 10000,
  connectionRetryTimeout: 90000,
  connectionRetryCount: 3,
  services: ['chromedriver'],
  framework: 'mocha',
  reporters: ['dot', 'spec', 'allure'],
  mochaOpts: {
    ui: 'bdd',
    timeout: 99999999
  },
}

【问题讨论】:

    标签: session webdriver-io


    【解决方案1】:

    试试这个解决方法。它实际上适用于我的 webdriverio v4

    • 在一个文件中列出所有规格。您可以利用您正在使用的 IDE 的自动完成功能,例如

      specs.js

      require('./test/specs/test1');
      require('./test/specs/test2');
      // etc.
      require('./test/specs/testN');
      
    • 在您的 wdio.conf.js 文件中,将上述 spec.js 文件列为唯一规范,即

      wdio.conf.js

      exports.config = {
          specs: ['./test/specs/specs.js'],
          // etc.
      }
      

    【讨论】:

      【解决方案2】:

      WebdriverIO 将在不同的会话中运行每个测试文件。要在同一个会话中运行它们,您需要将所有测试放在同一个文件中。

      如果您发现自己需要在同一个会话中运行所有测试,也许您应该重新测试您的测试...如果您需要进行通用设置,例如登录到一个网站。

      【讨论】:

      • 感谢您的回答,我正在为各种文件中的测试寻找解决方案。虽然我不知道如何使用 WebdriverIO 的 "before" hook 来解​​决这个问题,但谢谢我会尝试。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多