Skip to content

Instantly share code, notes, and snippets.

@SimitTomar
Created November 26, 2015 14:25
Show Gist options
  • Save SimitTomar/77c3aae7d8d7d29a62b7 to your computer and use it in GitHub Desktop.
Save SimitTomar/77c3aae7d8d7d29a62b7 to your computer and use it in GitHub Desktop.
@christian-bromann My question is around the Custom Commands. I went through the example given here: http://webdriver.io/guide/usage/customcommands.html
Based on that created to JS files
1) getUrlAndTitle.js: which contains the code for custom command:
client.addCommand("getUrlAndTitle", function(customVar, cb) {
this.url(function(err,urlResult) {
this.getTitle(function(err,titleResult) {
var specialResult = {url: urlResult.value, title: titleResult};
cb(err,specialResult);
console.log(customVar); // "a custom variable"
})
});
});
2) Test.js: which contains the step Definitions:
this.Then(/^I Select an appropriate Title$/, {timeout: 30 * 1000}, function (next) {
this.client
.init()
.getUrlAndTitle('a custom variable',function(err,result){
console.log('entered getUrlAndTitle');
})
.then(function() {
this.call(next);
});
});
But the Issue is that I am not getting .getUrlAndTitle as a command when I do this.client. , I just typed it manually in the step definition to see the output. Of course, the corresponding step is failing.
Is there anything that I am missing here, do I need to add the path of getUrlAndTitle.js in Test.js like
var getUrlAndTitle = require('tests/acceptance/wdio/utilities/helper/getUrlAndTitle.js');
or add the command in world.js
Please suggest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment