camme/webdriverjs — pull request #137 by christian-bromann (2014-03-05 23:07:56+00:00)
Title: event handling in WebdriverJS

It should be possible to register callbacks on events that could be influence the tests. For example:

```javascript
client.on('error', function(err) { ... });
client.on('command', function(data) { ... });
client.on('result', function(res) { ... });
client.on('end', function(data) { ... });
```

Also possible could be this syntax:

```javascript
client.onError(function(err) { ... });
client.onCommand(function(data) { ... });
client.onResult(function(res) { ... });
client.onEnd(function(data) { ... });
```

Are there any other events we should support?

Both should be possible to use since the implementation doesn't really cost any extra effort.

It could be also useful to register and listen to own events. A proper use case is when you have two WebdriverJS instances and two different browser (e.g. if you'ld like to test a chat client) then it would be really useful to have own events to tell the other instance to proceed with the test. It enables synchronizations between multiple tests.