Generic Cucumber Protractor Framework

raw JSON →
1.8.7 verified Sat May 09 auth: no javascript

A generic, reusable automation framework combining Cucumber, Protractor, and WebDriverJS for end-to-end testing of Angular and non-Angular applications. The current stable version is 1.8.7. It provides a large set of pre-built step definitions for form interactions, navigation, alert handling, REST API calls, and fake data generation. The framework is opinionated, requiring a specific folder structure and environment variables. It depends on Protractor, Cucumber, and several other libraries. Compared to building from scratch, this framework reduces boilerplate but may be overkill for small projects and is not actively maintained by a large community.

error Error: Cannot find module '../../node_modules/generic-cucumber-protractor-framework/support/pageObjects.js'
cause Relative path is incorrect or node_modules is not installed.
fix
Ensure the framework is installed via npm and use the correct relative path from your step file.
error TypeError: defineSupportCode is not a function
cause Using defineSupportCode from older versions of Cucumber (pre-v7).
fix
Update Cucumber to a version that supports defineSupportCode (e.g., 5.x) or switch to newer Cucumber API.
error WebDriverError: process exited with code null
cause Protractor driver session crashed; often due to incompatible browser driver version.
fix
Update WebDriver (e.g., npm install webdriver-manager@latest and run webdriver-manager update).
deprecated The framework may not be compatible with latest Protractor/Cucumber versions (e.g., Cucumber v7+, Protractor v7+).
fix Check GitHub for updates or consider migrating to a more modern framework like WebdriverIO + Cucumber.
gotcha Requires specific environment variables (WEB_SERVER, WEB_SERVER_PORT, etc.) to be set. Missing them may cause unexpected defaults or failures.
fix Ensure all required environment variables are defined in CI or local environment.
gotcha Folder structure must match expected layout exactly (e.g., /e2e/features/custom_steps). Deviation will break step loading.
fix Follow the documented folder structure strictly; do not rename or reorganize directories.
deprecated Old Cucumber support (`defineSupportCode`) is used. This is deprecated in Cucumber v7+.
fix If using Cucumber >6, update steps to use new API (e.g., `Given`, `When`, `Then` imports).
breaking The framework relies on Protractor's `browser.waitForAngular()`. It may time out on non-Angular pages.
fix Set `ignoreSynchronization = true` in your config or use `browser.waitForAngularEnabled(false)` before tests on non-Angular pages.
npm install generic-cucumber-protractor-framework
yarn add generic-cucumber-protractor-framework
pnpm add generic-cucumber-protractor-framework

Shows how to require the framework's support modules and define a custom Cucumber step.

// e2e/features/custom_steps/custom_steps.js
const { defineSupportCode } = require('cucumber');
const pageObjects = require('../../node_modules/generic-cucumber-protractor-framework/support/pageObjects.js');
const helpers = require('../../node_modules/generic-cucumber-protractor-framework/support/helpers.js');

defineSupportCode(function({ Then }) {
  Then(/^I see the "([^"]*)" element$/, async function(elementName) {
    const element = await pageObjects.findElement(this.page, elementName);
    await expect(element.isDisplayed()).to.eventually.be.true;
  });
});