Page tree
Skip to end of metadata
Go to start of metadata
Running your Selenium tests with WebdriverIO on Selenium Agent is easy. This guide will help you to set up your project in a few steps.

Requirements

  1. Node.js - 8.11.2 or higher.
  2. NPM  - Since WebdriverIO version 5, the test runner is in the @wdio/cli NPM package.
  3. User credentials or access key in Experitest Cloud.


Webdriverio setup


 Window setup

Setup your project

Make a new project directory manually or executing on the command line: 


Windows
#Create a new folder for the test
mkdir webdriverio-test && cd webdriverio-test
#Initialize on that directory a new npm project using
npm init -y
#Install webfriverIO CLI
npm i --save-dev @wdio/cli
#Generate configuration file
node_modules\.bin\wdio config -y
#Create a spec file
mkdir test\specs && cd test\specs
echo myTest > myTest.js
 Mac setup

Setup your project

Make a new project directory manually or executing on the command line: 

Mac
#Create a new folder for the test
mkdir webdriverio-test && cd webdriverio-test
#Initialize on that directory a new npm project using
npm init -y
#Install webfriverIO CLI
npm i --save-dev @wdio/cli
#Generate configuration file
./node_modules/.bin/wdio config -y
#Create a spec file
mkdir -p test/specs
cd test/specs
touch basic.js


Webdriverio test example

Open myTest.js file and write:

myTest.js Example
const assert = require('assert')
describe('webdriver.io page', () => {
    it('should have the right title', () => {
        browser.url('https://experitest.com')
        const title = browser.getTitle()
        assert.strictEqual(title, 'Experitest: Mobile App & Cross-Browser Testing End-to-End')
    })
})


For more advanced capabilities, Experitest offers you can go here.

wdio.config.js example
exports.config = {
    runner: 'local',
    hostname: <cloud-ip>,
    protocol: 'http',
    port: 80,
    path: '/wd/hub',

    specs: [
        './test/specs/**/*.js'
    ],
	capabilities: [{
	    accessKey:		'<AccessKey>', //Or userName, password and projectName if needed
		username:		'<cloudUsername>',
		password:		'<cloudPassword>',
		projectName:	'<cloudProject>', //only required if your user has several projects assigned to it. Otherwise, exclude this capability.
	    platformName:	'windows',                    //Optional
		browserVersion: '57',                         //Optional
		browserName:	'firefox',                    //Optional
	    testName:		'Selenium WebdriverIO test',  //Optional
		generateReport: true,                         //Optional
		agentName:		'<agentName>'                 //Optional
	}],

    logLevel: 'info',
    bail: 0,
    baseUrl: 'http://localhost',
    waitforTimeout: 10000,
    connectionRetryTimeout: 90000,
    connectionRetryCount: 3,
    framework: 'mocha',
    reporters: ['spec'],
    mochaOpts: {
        ui: 'bdd',
        timeout: 60000
    },
}

Webdriverio Run


 Window run

To run your tests, execute:

bash
node_modules/.bin/wdio run wdio.conf.js
 Mac run

To run your tests, execute:

bash
node_modules\.bin\wdio run wdio.conf.js







  • No labels