addCommand

Add custom command to client/browser instance. Read more about addCommand here.

Usage

1
client.addCommand(commandName,customMethod,overwrite).then(callback);

Parameters

Param Type Details
commandName String name of your custom command
customMethod Function your custom method
overwrite Boolean if set to true you can overwrite existing commands

Example

addCommand.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
client.addCommand("getUrlAndTitle", function(customVar) {
return this.url().then(function(urlResult) {
return this.getTitle().then(function(titleResult) {
console.log(customVar); // "a custom variable"
return { url: urlResult.value, title: titleResult };
});
});
});
 
client
.init()
.url('http://www.github.com')
.getUrlAndTitle('a custom variable',function(err,result){
assert.equal(null, err)
assert.strictEqual(result.url,'https://github.com/');
assert.strictEqual(result.title,'GitHub · Build software better, together.');
})
.end();