0

I am using Codeceptjs for automation testing in javascript which internally uses WebDriverIO. I have achieved to run on Sauce, using the mentioned framework.

I have accomplished to run automation test cases in different browsers in sauce lab by using desired capabilities but only one browser at a time.

Requesting help

  1. to parallelize the all test files runs on a single browsers in sauce lab.
  2. to parallelize the test runs on multiple browsers in sauce lab.

It would be great to have both of the above mentioned combinations.

What configuration should I provide to achieve the above two requirement on the WebDriverIO / CodeceptJS.

Here is my configuration that will be passed to sauce labs.

---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"
    }
  }
}

These are the list of desired Capabilities which i am using and picking one capability based on the selected browser name:

{
  "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"
  }
}
oligofren
  • 20,744
  • 16
  • 93
  • 180
pskushw
  • 1
  • 3

3 Answers3

1

I've never used CodeceptJS. However, as it uses Wdio, it could be possible to use maxInstances property to configure number of browers run in parallel.

Take a look at the Wdio documentation: http://webdriver.io/guide/testrunner/configurationfile.html

Andrii
  • 357
  • 2
  • 9
  • I tried everything here. However, I am not able to launch multiple browsers in parallel on my local machine. Just wanted to know whether WebdriverIO supports it? Running them on saucelabs or Browserstack is fine because they have their own Selenium grid implemented. How do we achieve this on local? – Shweta Sharma Mar 29 '19 at 17:26
1

Manual: parallel execution

Add to your 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"]
  }
}

multiple calling for selective browsers:

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

multiple calling for each browser in few chunks:

codeceptjs run-multiple parallel
fpsthirty
  • 185
  • 1
  • 4
  • 15
0

Below is the codecept config for single and multiple run

To execute in single browser run codeceptjs run as per below config test will run on FF only.

To execute multiple browser test run codeceptjs run-multiple --all it will execute your test on safari and chrome both as below config is for safari and 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
    }
  }
}
Gampesh
  • 4,024
  • 2
  • 12
  • 9