Having trouble executing cucumber tests using protractor

Whenever I run my tests, I keep encountering the error: TypeError: e.getContext is not a function

I am utilizing examples from https://github.com/cucumber/cucumber-js, making some modifications in world.js (to resolve timeout issues)

Application versions:

  • node 4.2.6
  • cucumber 0.9.4
  • protractor 3.0.0
  • protractor-cucumber-framework 0.3.3
  • zombie 4.2.1

My world.js:

// features/support/world.js
var zombie = require('zombie');
zombie.waitDuration = '30s';
function World() {
  this.browser = new zombie(); // this.browser will be available in step definitions
  this.visit = function (url, callback) {
    this.browser.visit(url, callback);
  };
}

module.exports = function() {
  this.World = World;
  this.setDefaultTimeout(60 * 1000);
};

My sampleSteps.js:

// features/step_definitions/my_step_definitions.js

module.exports = function () {
...
// The content of sampleSteps.js goes here.
...
};

My sample.feature:

# features/my_feature.feature

Feature: Example feature
...
// The content of sample.feature goes here.
...

My protractor-conf.js:

exports.config = {

  specs: [
    'features/**/*.feature'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://127.0.0.1:8000/',

    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
  // relevant cucumber command line options
  cucumberOpts: {
    require: ['features/support/world.js', 'features/sampleSteps.js'],
    format: "summary"
  }
};

Answer №1

I encountered a similar issue with this particular example. It seems to be related to the github.com page, although the exact nature of the problem is unclear to me.

To resolve this, I made some modifications to the page being visited and successfully ran tests without encountering the TypeError: e.getContext is not a function error.

The changes were made to the sampleSteps.js file:

module.exports = function () {
  this.Given(/^I am on the Google.com$/, function (callback) {
    // Implement the necessary code for visiting Google.com
    this.visit('http://www.google.com/', callback);
  });

  this.When(/^I go to the SEARCH page$/, function (callback) {
    // Include relevant code here and call callback() at the end.
    callback();
  });

  this.Then(/^I should see "(.*)" as the page title$/, function (title, callback) {
    this.browser.assert.text('title', title);
    callback();
  });
};

Additionally, adjustments were made to the sample.feature file:

Feature: Example feature
  As a user of Google.com
  I want to have search with Google
  So that I can find something

  Scenario: Search something
    Given I am on the Google.com
    When I go to the SEARCH page
    Then I should see "Google" as the page title

These changes should aid in getting started with cucumber-js and zombie.js smoothly.

This issue does not appear to be specific to Protractor, as I encountered the same problem when running this sample in WebStorm.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Every time I attempt to start a React project using CRA, it freezes and becomes unresponsive

I've been attempting to create a project using create-react-app, but it keeps hanging. I attempted to clear the cache, but unfortunately, it still hangs. One peculiar thing I noticed is the presence of a .staging file within node_modules, and inside ...

Dynamically importing files in Vue.js is an efficient way to

Here's the code snippet that is functioning correctly for me var Index = require('./theme/dir1/index.vue'); However, I would like to utilize it in this way instead, var path = './theme/'+variable+'/index.vue'; var Inde ...

Instructions for selecting all checkboxes in an HTML table with just one click

Developing an aspx page with 3 HTML tables, I am dynamically adding checkboxes to each cell. Additionally, I have a checkbox outside each table. When I check this checkbox, I want all checkboxes in the corresponding HTML table to be checked. However, curre ...

Adding HTML and scripts to a page using PHP and JS

Currently, I am utilizing an ajax call to append a MVC partial view containing style sheets and script files to my php page. Unfortunately, it seems that the <script> tags are not being appended. After checking my HTTP request on the network, I can ...

Experimenting with file uploads in AngularJS with the help of Protractor

For file uploads in our application, we are utilizing ngFlow. With protractor being used for testing, we have several test case scenarios to validate such as unsupported file formats and maximum file size limitations. How can we effectively select files ...

React with Typescript prop is functioning well, despite displaying an error

After creating a component and passing props to styled components, everything seems to be working fine. However, I keep encountering this error on the first prop. Component type WelcomeProps = { image: String, color: String } const StyledWelcom ...

Discovering the bound ASP.NET AJAX event handlers for a specific DOM element

I am currently working on customizing a pre-existing ASP.NET 3.5 AJAX web application, specifically SharePoint 2010. Unfortunately, I do not have the ability to modify the source code. My task involves adding a click event handler to act as the first even ...

Arranging images next to each other using CSS and HTML

I've been trying to arrange four images side by side, with two on the top row and two on the bottom. I want to ensure they stay consistent across all browser sizes except for mobile. Here is what I have attempted so far: #imageone{ position: absol ...

Efficient arrow function usage in jQuery map functionality

Looking to implement an arrow function in jQuery's map function. However, after trying the following code snippet, titlesText ends up being the correct length but with empty strings: let titles = $(panelBody).find('h4'); let titlesText = $(t ...

Challenges regarding OAuth2 and the angular-auth2-oidc Library - Utilizing PKCE Code Flow

As a newcomer to OAuth2 and the angular-auth2-oidc library, I may make some beginner mistakes, so please bear with me. MY GOAL: I aim to have a user click on the login link on the home page, be directed to the provider's site to log in, and then retu ...

Connections between Ember and mongo databases

Currently, I am exploring the most effective approach for my Ember App. I am dealing with two separate models: events and bookings. In my database, I have structured them in a completely independent manner. Schemas: Events: attributes: date : ...

Difficulty encountered when trying to customize a polymer element that has been expanded (paper-slider)

I've been customizing the Polymer paper-slider element to handle an enumerated list and cycle through these values in the slider instead of just showing numeric values. However, I'm struggling with getting the styles to align properly. When you r ...

Triggering the function once the text field is tapped again

I recently integrated a JavaScript scroll framework to create a stylish scrollbar for windows. I simply added it to a div: this.displayDiv = function () { $("#myDiv").niceScroll(); } <a href="#" onclick="manager.displayDiv();"> It ...

Quasar Troubles with Touch Swipe Gestures

I'm facing two issues, the first being that the directives are not functioning as expected. For example, I've implemented a swipe only to the right: <div class="q-pa-md row justify-center"> <q-card v-touch-swipe. ...

Disable javascript when using an iPad

I'm working on a website with parallax scrolling that I don't want to function on iPads. Is there a way to prevent the parallax effect from happening when the site is accessed on an iPad? Any guidance on how to disable parallax scrolling based o ...

What could be causing my newsletter form to malfunction on Amazon CloudFront?

I'm currently working with HTML on an Amazon EC2 instance (Linux free tier). I want to integrate CloudFront into my setup, but I'm encountering issues with my newsletter functionality. Despite not being an expert in AWS, I am struggling to unders ...

Sending data between Node.js middleware components

if (token_count == 1) { var user_name = rows[0].user_name; next(); } else { data = { message: "Invalid Token" } res.send(data); } I must pass the parameter user_name to function next(). When next() is called, it triggers the fo ...

What is the reason for the input type number in the <input> field being passed as a string?

I am currently developing a straightforward component that allows the user to input the balance they wish to add. Here is the template used for taking input from the user: <h3>Add Balance:</h3> <input #payment type="number"> < ...

What is the best way to include text in an editor access notification email?

I've developed a script to assign editors to a spreadsheet, but I'm looking to personalize the emails sent to them. The screenshot below illustrates the step where I can input a message for the email recipients who have been granted access. f ...

Showcase Pictures from a Document

Is there a way to upload an image via an input field and display it? I want to showcase a profile picture that can be saved in a database. The process should be simple for the user, with the ability to easily upload and view the image. function Save() { ...