WebdriverIO Example

WebdriverIO is supported by Gridlastic, run your tests in the cloud at blazing speed on real browsers. We also support other javascript frameworks like wd.js and Protractor AngularJS.

The Gridlastic hub endpoint and the video url used in this code example is displayed after launching your Gridlastic selenium grid. See documention Selenium Grid Configuration Parameters where to find these credentials and replace with your own.

Get a free account and launch your Gridlastic selenium grid, then run this code locally and test your grid!

Note: you must use the selenium client version equivalent to your selected selenium grid version. Example: If you selected to use selenium version 3.5.3 for your selenium grid (recommended for WebdriverIO until a stable selenium V4 version is released), install/use the equivalent selenium client version (3.53.x) in your local framework.

var webdriverjs = require('webdriverio'),
    client = webdriverjs.remote({
        desiredCapabilities: {
            browserName: 'chrome',
            version: 'latest',
            platform: 'WIN10',
            platformName: 'windows',
            video: 'True'
			},
        host: 'HUB_SUBDOMAIN.gridlastic.com',
        protocol: https,
        port: 443,
        user: USERNAME,
        key: ACCESS_KEY
    }).init();

 
client
    .url('https://www.google.com/ncr')
    .setValue('*[name="q"]','webdriverio')
    .click('*[name="btnG"]')
    .pause(1000)
    .session(function(err,res) {
    console.log("Video: " + VIDEO_URL + res.value['webdriver.remote.sessionid']);
	})
    .end();
Note: starting from selenium version 3.9.1 you must also include "platformName": "windows" in the request when testing with firefox and IE.



NOTE: Gridlastic auto scaling requires all 3 test environment parameters platform, browser and browser version to be specified in each request in order to launch test nodes to fulfill test demand. Video recording is optional. See test environments for capabilities options.
It is important to ensure that ".end()" is always called for proper test execution and creation of video recordings of failed tests.