无法在无头Chrome中运行我的CodeceptJS测试用例

阿舒托什·米什拉(Ashutosh Mishra)

我为我的应用程序设置了CodeceptJS框架,测试运行顺利。但是现在我希望他们使用无头铬。尝试了官方网站上提到的一些东西,但对我不起作用。

我尝试使用进行测试npx codeceptjs run --verbose

我的codecept.conf.js文件如下所示:

exports.config = {
  tests: './tests/features/**/*_test.js',
  output: './tests/output',
  helpers: {
    WebDriver: {
      smartwait: 10000,
      waitForTimeout: 10000,
      url: 'https://affinity.sourcefuse.com',
      browser: 'chrome',
      windowSize: 'maximize',
      chromeOptions: {
        args: [ "--headless", "--disable-gpu", "--window-size=800,600"]
      }
    }
  },
  include: {
    I: './steps_file.js',
    createDatasetPage: 'tests/pages/createDataset.js',
  },
  bootstrap: null,
  mocha: {},
  name: 'dashboard',
  plugins: {
    "allure": {
      "enabled": true
    },
    wdio: {
      enabled: true,
      services: ['selenium-standalone']
    }
  }
}

实际:Chrome已启动且测试开始运行。

预期:我希望它可以在无头的chrome上运行。

保罗·文森特·贝冈

chromeOptions需要包装desiredCapabilities,您的配置应如下所示:

exports.config = {
  tests: './tests/features/**/*_test.js',
  output: './tests/output',
  helpers: {
    WebDriver: {
      smartwait: 10000,
      waitForTimeout: 10000,
      url: 'https://affinity.sourcefuse.com',
      browser: 'chrome',
      windowSize: 'maximize',
      desiredCapabilities: {
        chromeOptions: {
          args: ["--headless", "--disable-gpu", "--no-sandbox"]
        }
      }
    }
  },
  include: {
    I: './steps_file.js',
    createDatasetPage: 'tests/pages/createDataset.js',
  },
  bootstrap: null,
  mocha: {},
  name: 'dashboard',
  plugins: {
    "allure": {
      "enabled": true
    },
    wdio: {
      enabled: true,
      services: ['selenium-standalone']
    }
  }
}

我已windowSize从中删除args因为它已经设置windowSize并添加了no-sandbox它,因为它建议用于测试自动化。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Chrome中运行Selenium WebDriver测试用例?

无法在Docker容器中运行Angular测试用例

无法从Ant运行Groovy测试用例

无法运行单元测试用例

无法运行 jest 测试用例

Django测试用例无法运行方法

公理测试用例无法运行

由于chromedriver与chrome版本不匹配,导致E2e测试用例在角度中无法运行

带文件下载的Angular ng e2e测试用例不适用于无头Chrome

测试用例在chrome中失败

带有无头镶边的水豚无法清除使用不同子域的测试用例之间的会话

当我运行 Spring Boot 测试用例时出现错误,我无法自行解决

无法覆盖 Junit 中的测试用例?

我可以在Robot Framework中按测试用例重新运行失败的测试吗?

我编写的实用程序无法正常运行+测试用例

我无法正确运行所有测试用例,怎么了?

Laravet 测试用例失败,无法在测试用例上运行种子

在测试套件中重新运行失败的测试用例

使用UI测试用例在Android Studio中运行测试

我在使用 chrome 无头运行 selenium 测试时遇到问题

在Eclipse中运行Robot测试用例-无法找到输出控制台

无法在cmd行的Robot Framework中基于标签运行测试用例

无法在 Jenkins 管道的 docker 容器中运行 jasmine 测试用例

我如何在 TestNG 中运行来自同一类的多个测试用例

在未运行测试用例的函数中创建单元测试用例类

无法从IntelliJ IDEA运行JUnit-5测试用例

无法使用IRetryAnalyzer运行失败的测试用例

如何配置Jenkins以并行运行我的测试用例?

为什么我的Javascript代码无法在Chai中通过单元测试用例