How can we troubleshoot webdriver cucumber when test steps are skipped due to passed arguments?

Greetings! I have a feature file outlined below in my cucumber webdriver test project:

# language: en
Feature: Simple Test, Int and Prod Origin vs non origin checks

  Simple cloud environment Checks

  @javascript @EnvCheck
  Scenario: Check Env TEST Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

  @javascript @EnvCheck
  Scenario: Check Env TEST non Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

  @javascript @EnvCheck
  Scenario: Check Env INT Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

  @javascript @EnvCheck
  Scenario: Check Env INT non Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

  @javascript @EnvCheck
  Scenario: Check Env PROD Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

  @javascript @EnvCheck
  Scenario: Check Env PROD non Origin
    Given I open the url "some_url"
    When nothing
    Then I expect that element ".b-stage" is displayed

Furthermore, I have the specified Step for the test case:

import { Then } from "@cucumber/cucumber";

Then(/^I expect that element "(.*)" is displayed$/, (element) =>; {

    console.log(element);
    
})

I am encountering a peculiar issue where my "Then" step is being skipped when I include an argument such as ".b-stage" as an element. Oddly enough, the "Given" and "When" steps execute successfully without any issues, but the "Then" step is inexplicably skipped.

I have meticulously followed the steps outlined in a video tutorial found here Chapter 4.3 - Step Definitions[^], yet I continue to encounter the same problem of skipped "Then" test cases when passing an element as an argument to the step. The debug logs displayed are as follows:

[Debug logs displayed here]

I have attempted to remove the element argument from the "Then" step, and it passes successfully. However, upon reintroducing the element argument, specifically as ".b-stage" in the feature file, the step stops working and skips the "Then" test case. Strangely, the "Given" test case executes flawlessly without any errors.

Answer №1

Your Then must establish an expectation in order to be effective. Without setting an expectation, it will simply pass by unnoticed. One way to test this is by:

a) Adding a debug statement before the Then block

b) Including a clear expectation in the Then block

When using Ruby and Capybara for my testing, I typically follow these steps:


To mimic this in your JavaScript environment:
Then 'I should see bstage' do
  byebug
  console...
end

For adding expectations:

Then 'I should see bstage' do
  expect(page).to have_css('.bstage')
end

It's important to replicate these steps in your JavaScript environment as well.

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

How to execute a function *after* another function has finished running in Javascript upon page load?

I am currently using scrollsaver.js to maintain scroll positions of elements after postback. However, I have encountered difficulties in resetting the scroll position when needed. Specifically, when paging through a list, I want the scroll position to res ...

Puppeteer's flawed performance leads to the generation of low-quality

Currently, I am utilizing puppeteer to generate a PDF from my static local HTML file. However, the resulting PDF is turning out to be corrupted. When attempting to open the file using Adobe Reader, an error message pops up stating 'Bad file handle&apo ...

The exception thrown by Runtime.callFunctionOn was due to an error in LavaMoat - the property "Proxy" of globalThis is not accessible in scuttling mode

As I work on developing a Next.js app, I encountered some challenges when trying to run tests with selenium-webdriver. My webapp utilizes authentication with Metamask wallets, and the issue arises when attempting to import a wallet into a test window using ...

Identifying the conclusion of a folder being dropped in vanilla JavaScript

I am working on determining when a directory tree has been completely traversed after being dropped onto a page. My goal is to identify the point at which the next process can begin once the entire folder and its sub-directories have been processed by the ...

Selenide is experiencing difficulties when attempting to download PDF files

Encountered some challenges while trying to use Selenide's download feature. Here is the sequence of events: Clicked on a button The button opened a new tab displaying a PDF file with the following URL: blob: Essentially, the new tab opens in Chrome ...

What could be causing the return of undefined upon execution?

function updateTitle(title) { title = "updated title"; } var currentTitle = "original title"; currentTitle = updateTitle(currentTitle); console.log(currentTitle) I'm just starting to learn JavaScript and I'm curious about why this code behav ...

Tips for transferring information from Django to React without relying on a database

Currently, I am in the process of developing a dashboard application using Django and React. The data for the user is being pulled from the Dynamics CRM API. To accomplish this, I have implemented a Python function that retrieves all necessary informatio ...

Implementing the Google Maps API into a React application to generate a customized route between two specified points

I'm currently developing a React application that is designed to display the distance between two points on a map. Although I successfully implemented this feature using JavaScript and HTML, I am facing challenges in converting it to React as I am re ...

Modify the numerical presentation within the provided input text

Looking to format numbers in the thousands with a comma, for example changing 2000 to 2,000 and 20000 to 20,000. While I found a solution using cleave.js library, it only works for one input field. Is there another alternative that can handle multiple in ...

Guide to locating a particular node within an array of nested objects by utilizing the object

Dealing with an array of nested objects, the goal is to compare values with a flat array and update the property matchFound. If the parent's matchFound is true, then all its children should inherit this value. treeData = [{ field: 'make&a ...

Guide on performing an inner-join query in Firestore using NextJS

My Firestore database contains two collections that I need to work with. The 'uid' field in the users collection and the 'createdBy' field in the 'anuncios' collection both store the same string data, linking each 'anunc ...

Unspecified origins of Js in Chrome Extension

console.log(chrome.runtime.sendMessage({from:"script2",message:"hello!"})); However, attempting to send the message from a background script to a content script is proving to be unsuccessful. https://i.stack.imgur.com/ERgJB.png ...

Connect the AngularJS data model with a Foundation checkbox element

I am attempting to link a model (a boolean value) to a checkbox created with Foundation (Zurb). I have created a small demonstration displaying the issue: http://jsfiddle.net/JmZes/53/ One approach could involve simply creating a function that triggers o ...

How can you use jQuery to display an image when hovering over text?

Looking for a tutorial or script that displays an image when hovering over HTML text with the mouse? ...

Dealing with Web Page Session Timeout (logging out from the application) - Java WebDriver

In our application, the session times out after 15 minutes of inactivity as designed. However, my automated script using Selenium WebDriver keeps performing actions continuously, causing the application to time out mistakenly. Even though the script is ac ...

Issue with loading dynamic content on a webpage using HTML and JavaScript through AJAX

I am currently using the jQuery UI Tabs plugin to dynamically load HTML pages through AJAX. Here is the structure of the HTML code: <div id="tabs"> <ul> <li><a href="pageWithGallery.html" title="pageWithGallery">Gallery< ...

Cannot locate AngularJS + Typescript controller

I'm encountering an error while attempting to integrate TypeScript with AngularJS. The issue I'm facing is: Error: [$controller:ctrlreg] The controller named 'MyController' has not been registered Does anyone have any insights on what ...

Jquery doesn't immediately hide an element after the first click.TabPage.getSelection().extentNode rectangular_HTML

I'm experiencing a peculiar issue with an event listener $(document).on('click', '.suggested-location-item', function(event) { event.preventDefault(); $('#IDsuggestedLocationsList').html(''); $(&apo ...

Add-on or code snippet for Node.js that allows for optional regex groups

Strings in Sequence line 1 = [A B C] line 2 = [A C] line 3 = [B C] Regular Expression /\[?(?<groupA>[A])?(?:[ ]*)?(?<groupB>[B])?(?:[ ]*)?(?<groupC>[C])\]/gm Is there a way to achieve the desired output using a plugin or spe ...

Error: The 'geckodriver' executable must be located within the PATH directory

Recently, I encountered an issue while trying to deploy a Flask app on a production server using Firefox Geckodriver. The server runs on Ubuntu 18.04 with nginx installed and the application itself is a image detection Flask Python program. Oddly enough, t ...