38 lines (28 sloc) 1.08 KB


World is an isolated context for each scenario, exposed to the hooks and steps as this. The default world constructor is:

function World({attach, parameters}) {
  this.attach = attach
  this.parameters = parameters
  • attach: function used for adding attachments to hooks/steps
  • parameters: object of parameters passed in via the CLI

The default can be overridden with setWorldConstructor.

var {setWorldConstructor} = require('cucumber');
var seleniumWebdriver = require('selenium-webdriver');

function CustomWorld() {
  this.driver = new seleniumWebdriver.Builder()

  // Returns a promise that resolves to the element
  this.waitForElement = function(locator) {
    var condition = seleniumWebdriver.until.elementLocated(locator);
    return this.driver.wait(condition)


Note: The World constructor was made strictly synchronous in v0.8.0.