0

我在内部使用 WebDriverIO 的 javascript 中使用 Codeceptjs 进行自动化测试。使用上述框架,我已经实现了在 Sauce 上运行。

我已经完成了在酱实验室的不同浏览器中运行自动化测试用例,方法是使用所需的功能,但一次只能使用一个浏览器

请求帮助

  1. 并行化所有测试文件在酱实验室的单个浏览器上运行。
  2. 在酱实验室的多个浏览器上并行测试运行。

拥有上述两种组合会很棒。

我应该提供什么配置才能在 WebDriverIO / CodeceptJS 上实现上述两个要求。

这是我将传递给酱汁实验室的配置。

---codecept.conf.js---

WebDriverIO: {
  url: "http://localhost:3000",
  browser: chrome,
  waitforTimeout: 60000,
  restart: false,
  logLevel: "silent",
  cssSelectorsEnabled: "true",
  timeouts: {
    script: 60000,
    "page load": 60000,
    implicit : 0
  },
  "host": "ondemand.saucelabs.com",
  "port":80,
  "user":"<SAUCE_USER_NAME>",
  "key": "<SAUCE_ACCESS_KEY>”,
  desiredCapabilities :{
    "chrome": {
      "browserName": "chrome",
      "name": "TEST_CHROME",
      "platform": "ANY",
      "version": "55.0"
    }
  }
}

这些是我正在使用的所需功能列表,并根据所选浏览器名称选择一项功能:

{
  "internet explorer": {
    "browserName": "internet explorer",
    "name": "TEST_IE",
    "platform": "Windows 7",
    "ignoreZoomSetting": true,
    "nativeEvents": false,
    "ignoreProtectedModeSettings": true,
    "version": "11"
  },
  "chrome": {
    "browserName": "chrome",
    "name": "TEST_CHROME",
    "platform": "ANY",
    "version": "55.0"
  },
  "firefox": {
    "browserName": "firefox",
    "name": "TEST_FIREFOX",
    "platform": "ANY",
    "version": "51.0"
  },
  "safari": {
    "browserName": "safari",
    "name": "TEST_SAFARI",
    "platform": "OS X 10.11",
    "version": "10.0"
  },
  "opera": {
    "browserName": "opera",
    "name": "TEST_OPERA",
    "platform": "Windows 7",
    "version": "ANY"
  },
  "MicrosoftEdge": {
    "browserName": "MicrosoftEdge",
    "name": "TEST_IEEdge",
    "platform": "Windows 10",
    "version": "13"
  }
}
4

3 回答 3

1

手册:并行执行

添加到您的 codecept.conf.js:

"multiple": {
  "internet explorer": {
    "browsers": ["internet explorer"]
  },
  "chrome": {
    "browsers": ["chrome"]
  },
  "firefox": {
    "browsers": ["firefox"]
  },
  "safari": {
    "browsers": ["safari"]
  },
  "opera": {
    "browsers": ["opera"]
  },
  "MicrosoftEdge": {
    "browsers": ["MicrosoftEdge"]
  },
  "parallel": {
    // Splits tests into chunks
    // for example: 2 chunks x 6 browsers = 12 threads
    "chunks": 2,
    // run all tests in each browser:
    "browsers": ["internet explorer", "chrome", "firefox", "safari", "opera", "MicrosoftEdge"]
  }
}

多次调用选择性浏览器:

codeceptjs run-multiple chrome opera "internet explorer" firefox // create threads (four in all) for each browser: chrome, opera, internet explorer and firefox.

以几个块对每个浏览器进行多次调用:

codeceptjs run-multiple parallel
于 2018-12-05T13:30:20.307 回答
1

我从未使用过 CodeceptJS。但是,由于它使用 Wdio,因此可以使用maxInstances属性来配置并行运行的浏览器数量。

看看 Wdio 文档:http ://webdriver.io/guide/testrunner/configurationfile.html

于 2017-04-15T04:51:58.237 回答
0

以下是单次和多次运行的 codecept 配置

要在单个浏览器中执行 codeceptjs run,按照以下配置测试将仅在 FF 上运行。

要执行多个浏览器测试运行codeceptjs run-multiple --all ,它将在 safari 和 chrome 上执行您的测试,因为以下配置适用于 safari 和 chrome。

  tests: '**/.funcspec.js',
  output: './output',
  helpers: {
    WebDriver: {
      url: '<YOUR URL>',
      browser: "firefox",
      show:true,
      desiredCapabilities: {
        'record_video': 'true',
         name: 'Single browser run',
      },
      "user": "USERNAME",
      "key": "KEY"
    }
  },
  multiple: {
    smoke:{
      browsers: [
        {
          browser: 'Safari',
          desiredCapabilities: {
            version: "latest-1",
            platform: 'OS X 10.11',
            name: 'Safari Parallel run',
          }
        },
        {
          browser: "Chrome",
          desiredCapabilities: {
            version: "latest-1",
            platform: 'Windows 10',
            name: 'Chrome Parallel run',

          }
        },
      ],
    },
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'somename',
  plugins: {
    pauseOnFail: {},
    retryFailedStep: {
      enabled: true
    },
    tryTo: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}
于 2021-10-28T10:23:58.427 回答