Failure of Cucumber Step due to Incorrect Step Executed

There seems to be an intentional failure in the following step test:

Then(/^the 150 button has been deselected$/, function () {
    driver.sleep(5000);
    var checboxValue = driver.findElement(By.css('#app > div > div > div > div.col-xs-offset-2.col-xs-10 > div > div > div:nth-child(3) > div:nth-child(1) > div:nth-child(6) > div > label:nth-child(2) > input[type="checkbox"]'))
    checboxValue.isSelected()
      .then((val) => { return assert.equal(val, true) })
  })

Despite intentionally failing the above step, the next step fails with the correct error message:

When(/^Date 1 is entered$/, function () {
    var dateInput1 = driver.findElement(By.css('#app > div > div > div > div.col-xs-offset-2.col-xs-10 > div > div > div:nth-child(3) > div:nth-child(1) > div:nth-child(5) > div > div:nth-child(1) > input'));
    dateInput1.click();
    driver.sleep(8000);
    return dateInput1.sendKeys('2017-07-13');
  })

The command line output looks like this:

(tick)Then the 150 button has been deselected # features\step_definitions\task_2.js:23
   × When Date 1 is entered # features\step_definitions\task_2.js:30
       AssertionError: false == true
           + expected - actual

           -false
           +true

It's puzzling why the 'Then' step passed and the 'When' step failed as it should not have been executed due to the previous step failing.

Any insights or explanations would be appreciated.

Answer №1

Consider utilizing the alternative package available at github.com/djungowski/cucumber-assert. It appears that the issue may be related to the usage method.

var assert = require('cucumber-assert');

module.exports = function() {

    this.Given(/^the field E-Mail is filled with "([^"]*)"/, function (email, callback) {
        var fieldValue = this.getFieldValue('#password');
        assert.equal(fieldValue, email, 'Expected E-Mail to be ' + email).then(callback, callback);
    });

}

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

Can you explain the distinction between using get() and valueChanges() in an Angular Firestore query?

Can someone help clarify the distinction between get() and valueChanges() when executing a query in Angular Firestore? Are there specific advantages or disadvantages to consider, such as differences in reads or costs? ...

Express is having trouble providing data to React

Currently, I am delving into mastering the realms of React and Express. My ongoing project involves crafting a learning application that fetches data from MySQL and renders it visually for analysis. To kickstart this endeavor, I set up a basic express ser ...

The method window.scrollTo() may encounter issues when used with overflow and a height set to 100vh

Suppose I have an HTML structure like this and I need to create a button for scrolling using scrollTo. However, I've come across the information that scrollTo doesn't work well with height: 100vh and overflow: auto. What would be the best way to ...

Bootstrap Table encountering issues when displaying JSON data from Ajax response

I am currently struggling with an unusual issue. I have received a successful JSON response from the server, which I need to display in my Bootstrap Table. However, I am facing difficulty in displaying the JSON data in the Bootstrap Table while using AJAX ...

When attempting to access /test.html, Node.js server returns a "Cannot GET"

Embarking on the journey of diving into Pro AngularJS, I have reached a point where setting up the development environment is crucial. This involves creating an 'angularjs' directory and placing a 'test.html' file in it. Additionally, o ...

There is an unbound local error popping up in the script I created using Selenium for my user

I am facing an issue with a program that scrapes data from a web app. The program is running fine on my computer, but the user keeps encountering an unbound local error in the box_input method. Here is the error screenshot sent by the user. I'm unsur ...

What is the best way to switch between three different menus and ensure that the last selected menu remains open when navigating to a new page

My knowledge of javascript, jquery, and php is pretty much non-existent, unfortunately. I only have a grasp on html and css at the moment. However, I will be starting school to learn these languages in the fall! The issue I am currently facing is creating ...

Make a decision within Express.js to select the appropriate middleware modules based on specific conditions

In my express.js endpoint, I am dynamically selecting between middleware callbacks to execute: const middleware1 = require('./m1') const middleware2 = require('./m2') app.get('/call', async (req, res) => { if (req.code == ...

Ways to customize the appearance of a react-chartist component

I recently created a React JS component that utilizes the amazing react ChartistGraph component. However, I've run into an issue where the default CSS of ChartistGraph seems to be conflicting with my custom styling. While there is plenty of documentat ...

Python program that alerts the user when a specific word is detected on a webpage

I am interested in receiving notifications whenever a specific word appears on a website. For example, on a news site, if there is an update that includes the word "GST", I would like to be notified and receive the details of that news to save in a file. ...

Is there a way to open an app using a custom scheme without triggering the "open in <appname>" warning?

Trying to launch my app from Safari using a custom scheme specified in the info.plist: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.appvendor.rentalapp</ ...

The typical number of keys in a ChartJS graph is 2

Currently, I am utilizing ChartJS for a project that displays user-added records such as weight and heart rate for tracking purposes. I have encountered an issue where if a user adds two slightly different value records for the same day, it results in both ...

Having trouble with React useref in typescript - encountering an error

Currently, I am in the process of developing a tabs component using React and TypeScript. This component allows users to scroll through tab links from left to right at the top, with overflow: scroll enabled. While this functionality works seamlessly with a ...

Enhancing ajax post requests made with vanilla javascript by incorporating variables

I have successfully implemented a post ajax request in vanilla Javascript, but I am facing an issue. I need to include a variable in form_data that will be sent to PHP. For instance, the variable apple = 1 is already part of form_data. Now, I also want to ...

Ways to extract metadata from a given URL

Recently, I've delved into the world of JavaScript and I'm looking to extract metadata from a given URL. Whenever a URL is entered into an input field, I want to retrieve its meta data - a simple task in HTML using JavaScript. However, every time ...

Guide to acquiring the webViewLink using Google Drive Api v3?

I'm having trouble locating the webViewLink. The documentation (https://developers.google.com/drive/api/v3/reference/files) states that I should receive this parameter when requesting gapi.client.drive.files.list(). However, I don't even have a c ...

What is the best way to tailor my functions to apply only to specific objects within an array, instead of affecting them all?

I am facing an issue where my functions showMore and showLess are triggering for all objects in the array when onClick is fired. I want these functions to be called individually for each object. Both of these functions are responsible for toggling betwee ...

AngularJS display of SQL Server PIVOT table results

I am facing a challenge in returning data from the SQL server to the view. My question is about how to dynamically return column titles from the database to a table in an Angular app view. As new entries are added to the person table in the database, new c ...

Click event not being triggered in Handlebar JS

VIEW DEMO Hey there, I've been struggling to implement a simple click event for dynamically loaded JSON data in an anchor tag. I've tried using both vanilla JavaScript and jQuery but haven't been successful in making it work. The same func ...

Trigger an alert using the Ajax response

Is there a way to display the value of imageX outside of the $.ajax() function? var imageX; $.ajax({ type: 'GET', url: 'php/my1.php', dataType: 'json', async: 'false', success: function(response) ...