Eventhandling
The following functions are supported: on
,once
,emit
,removeListener
,removeAllListeners
.
They behave exactly as described in the official NodeJS docs.
There are some predefined events (error
,init
,end
, command
) which cover important
WebdriverIO events.
Example
1 2 3 4 5 6
| client.on('error', function(e) { console.log(e.body.value.class); console.log(e.body.value.message); })
|
All commands are chainable, so you can use them while chaining your commands
1 2 3 4 5 6 7 8 9 10 11 12
| var cnt; client .init() .once('countme', function(e) { console.log(e.elements.length, 'elements were found'); }) .elements('.myElem').then(function(res) { cnt = res.value; }) .emit('countme', cnt) .end();
|