Skip to main content

Grid Execution with WebdriverIO

There are two main aspects of running WebdriverIO tests in the grid. The first aspect is initiating a test session and the other is running a test in parallel on multiple devices.

Initiating a Test Session

To initiate a test session and run a WebdriverIO test on the grid, certain capabilities must be specified in the Desired Capabilities object. The capabilities are:

  1. Authentication with WebdriverIO

  2. Cloud URL - the URL of the cloud.

In addition, the WebdriverIO test desired capabilities may include the following capabilities:

  • testName - Specifies the test name. This name will appear in SeeTest Reporter and in the generated report

  • generateReport - By default every WebdriverIO test generates a report and takes screenshots after each command. To disable reports (and screenshots) pass this capability with a false value

  • takeScreenshots - take a screenshot of reports and the device reflection in the Grid page

  • platformName - run the test on the specified platform (Mac, Windows, iOS, etc...)

  • browserName - run the test on the specified browser (default is chrome)

  • browserVersion - run the test on the specified browser version (check which version are supported in your lab)

  • waitforTimeout - Default timeout for all waitFor* commands.

  • connectionRetryTimeout - Default timeout in milliseconds for request if Selenium Grid doesn't send a response.

    In order to use Continuous Testing additional capabilities, you should use the following format:

    'experitest:testName' : 'here is the test name',

If the WebdriverIO test is configured to generate a report when the test is finished a detailed report will be created in SeeTest Reporter.

Below you can find an example written in Javascript specifying the capabilities above.

WebdriverIO- Grid Execution

exports.config = {
host: '<cloudurl>',
port: <port>,
path: '/wd/hub',
protocol: 'https', //or http if the cloud doesn't use SSL

maxInstances: 10, //how many tests should run in parallel

capabilities: [{
'experitest:generateReport' : false,
'experitest:takeScreenshots' : false,
'browserName': 'chrome',
'platformName': 'mac',
'browserVersion': '61'
}],

waitforTimeout: 60000,
connectionRetryTimeout: 90000,

......
}

Parallel Execution

If you run a test using the capabilities as they appear above, it will run on one device only. However, if you run this test on multiple threads, every thread creates a different instance of the test class which in turn initiates another test request. Running tests in parallel requires that you understand the concept of multi-threaded execution (either by built-in specific language implementations or using unit testing frameworks). It also requires that your license includes the ability to run tests on multiple nodes. For more information about these two aspects, visit our documentation on the subject.