I do not think you can. In the AfterFeatures the cucumber process has already finished, so this no longer references it.
But, if all you want is to visit a page, you can register your browser outside cucumber so that it is still accessible from the AfterFeatures hook. If you are using AngularJS + Protractor, Protractor handles the browser for you, and therefore it is still accessible in the AfterFeatures hook. It would be the same principle. This can be done with the following.
hooks.js
var myHooks = function () {
this.registerHandler('AfterFeatures', function (event, callback) {
console.log('----- AfterFeatures hook');
// This will not work as the World is no longer valid after the features
// outside cucumber
//this.visit('/quit', callback);
// But the browser is now handled by Protractor so you can do this
browser.get('/quit').then(callback);
});
};
module.exports = myHooks;
world.js
module.exports = function() {
this.World = function World(callback) {
this.visit = function(url) {
console.log('visit ' + url);
return browser.get(url);
};
callback();
};
}
The AfterFeatures example in the cucumber-js GitHub repository is a little misleading, as it looks like you can access the driver that you previously registered in the World. But if you are using pure cucumber-js only, I have not seen that work.
By the way, you can use just this instead of registerHandler.
this.AfterFeatures(function (event, callback) {
browser.get('/quit').then(callback);
});
Hope this helps.