How to deal with data tables in Cucumber and Protractor


So, today I will give a code snippet about how to deal with Cucumber data tables and protractor.

Following the example:


  • Scenario with data table:
 Scenario: Register multiple users from different countries
   Given I want to register multiple users
    | user  | country  |
    | nicko | uk       |
    | pitty | brazil   |
    | slash | us       |
   When I send the form
   Then all the users should be registered


Remember to create the data table with the headers. Don’t forget that data tables are different from examples, here the first step will create a hash table with the data from the table and send it as parameter. Examples are used to run the same scenario with different variables in each run.


  • Related Step Definitions:
'use strict';

var protractor = require('protractor');
var browser = protractor.browser;
var _ = require('lodash');
var Q = require('q');

var RegisterPageSteps = function() {

 this.Given(/^I want to register multiple users$/, function(data) {
    var promises = [];
    var rows = data.hashes();
    //For each row you will get the user and the country
    _.each(rows, function(row) {
       var user = row.user;
       var country =;

       //Here you can add the promises to perform sequentially
       //you can call the promises passing the user and the 
       //country as parameters
       promises.push((addUserCountry(user, country));

    //You can also have promises to be performed that don't need
    //the parameters from the data table

    //Here you return all the promises
    return Q.all(promises);

 this.When(/^I send the form$/, function(callback) {

 this.Then(/^all the users should be registered$/, function(callback) {


module.exports = RegisterPageSteps;


I have not implemented other functions and steps as the aim here is to show how to deal with the data table in your scenario.

Thank you !

How to setup Protractor + Cucumber

Hello guys, I will post about how to install protractor and cucumber to test an AngularJS and how to import this project on your Eclipse.

You need JDK and Node.js installed:

– Install node in your mac

brew install node
node --version

– Check the version of you java

java -version

– Git clone this project as an example:

– Install protractor and cucumber through npm, update and start the webdriver server

npm install -g protractor
npm install -g cucumber
protractor --version
webdriver-manager update
webdriver-manager start

– You will see a message like this on your console:

11:13:08.586 INFO - Selenium Server is up and running

– Run cucumber.js on the protractor-cucumber’s project folder

– If you have the error below, move the features folder to outside the examples folder and open the /features/step_definitions/steps.js and remove one of the “../”:

  return binding.lstat(pathModule._makeLong(path));


Error: ENOENT: no such file or directory, lstat '/Users/Documents/workspace/protractor-cucumber/features'

    at Error (native)

    at Object.fs.lstatSync (fs.js:887:18)

    at Object.realpathSync (fs.js:1518:21)

    at Object.expandPathWithExtensions (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli/path_expander.js:14:23)

    at /usr/local/lib/node_modules/cucumber/lib/cucumber/cli/path_expander.js:8:27

    at (native)

    at Object.expandPathsWithExtensions (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli/path_expander.js:7:31)

    at Object.expandPaths (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli/feature_path_expander.js:9:38)

    at Function.Configuration (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli/configuration.js:21:63)

    at getConfiguration (/usr/local/lib/node_modules/cucumber/lib/cucumber/cli.js:46:38)

Rafaelas-MBP-2:protractor-cucumber rafaelasouza$ cucumber.js



If you want to run on Eclipse:
– Install nodeclipse, a Node.js plugin for Eclipse

npm install -g nodeclipse

nodeclipse -g

– Import this project into your workspace and install Enide on your eclipse.

Thank you guys ! See you tomorrow !