Even with the correct Step Definition in place, Cucumber is struggling to locate it

While setting up the Selenium Cucumber framework, I encountered a problem. Even though the step definition path is correctly defined in the glue, it somehow cannot locate the cucumber step definition.

Here are the installed jars: Cucumber-java, Cucumber-core, Cucumber-junit, gherkin, junit, selenium standalone

TestRunner

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/java/features",glue={"src/test/java/stepDefinitions"})
public class TestRunner {

}

Folder Structure

https://i.stack.imgur.com/8Q9Po.png

I attempted using Cucumber Java 8, but I couldn't even access the Given, When, Then annotations.

Answer №1

Consider updating the glue definition as shown below:

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/java/features",
        glue = "stepDefinitions"
)
public class TestRunner{

}

Make sure to replace stepDefinitions with the correct package name of your step definition file.

You do not need to include the full path in the glue definition.

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

The REST Client is reporting back with an HTTP status code of 401

Thank you for taking the time to read this! Overview: I have developed a JAVA REST client that authenticates with a username and password, returning a JSON response. Issue: I am encountering the following exception: Error in thread "main" java.io.IOExc ...

PageFactory error: incorrect number of parameters

I am currently practicing on homedepot.com and I have encountered a question. The error message reads: "Arity mismatch: Step Definition 'StepsTestCase.SearchShoppingStep.click_close_button_in_add_to_cart_window(WebDriver) in file:/C:/Users/Administrat ...

What is causing my constant failures in Jenkins / Ant builds?

Trying to understand Jenkins has been a challenge for me. Despite the success of building and running my suite of selenium tests in Eclipse and through the command line with ant, I encounter failures when attempting to use Jenkins. Interestingly, the conso ...

Tips for utilizing one catch block to handle both TestNG assertion errors and RunTime exceptions

In my TestNG framework with Java and Selenium, I have created two custom methods to handle WebElement interactions. Here they are: // Checks if a WebElement is present on the screen public boolean isElementPresent(WebElement element) { try { e ...

Why is my Selenium program consistently throwing a NoSuchElementException regardless of the type of element query I try?

Looking for a solution to an issue with my Selenium code. I am attempting to extract data from a stock data website but keep encountering a NoSuchElementException. When using a JS query in the Chrome developer console, everything works fine: document.getE ...

Parsing Json in Android does not provide any results

I have a JSON parsing Class structured like this: public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; public JSONParser() { } // method to fetch json from URL // using HTTP POST or GET method ...

Discovering the xpath with a certain condition based on text length using Python Selenium

In my quest to extract the specific content I need from countless pages, I have devised a reliable rule that works 99% of the time: //a[@class='popular class' and not (contains(text(),'text1')) and not (contains(text(),'text2&apos ...

Tips for verifying and controlling dropdown values using WebDriver?

Is there a way to check the status of percentage values in a drop-down, where some are enabled and others disabled? I am looking for a method to obtain the XPath of a specific value and determine if it is enabled or disabled. Click on the image below for ...

Extract data from a multi-page table using Jsoup

Currently, I am working on extracting player statistics from the table of data found on this website using jsoup and selenium in java. However, I have encountered a problem when attempting to parse a table that spans multiple pages. Does anyone have any s ...

Creating an executable from a test file located in a separate directory within the current folder

I am facing an issue with compiling a test file in Java with the files Triangle.java and TriangleTest.java located in different folders. The directory structure is set as C:\Users\A\Desktop\NewPrograms, organized into separate folders f ...

Python Selenium script that includes printing to the command line in the middle

first_run = res_loop(url, tr) if first_run > 0: xml_input = first_run else: loop_decision = input("Do you want to run the script until a time slot is found?\n") if loop_decision[0].upper() == 'Y': loop_outpu ...

HttpErrorResponse: unexpected internal server error

Just getting started with Angular 6. I created a post service using Spring Boot, and it works perfectly when tested with Postman. But testing it in a web browser results in the following error: HttpErrorResponse {headers: HttpHeaders, status: 500, statusT ...

Are there alternative, more dependable methods for executing a click command on an element in Headless Chrome using Selenium?

For the past two days, I have been struggling with a frustrating issue involving the click() command in Headless Chrome. Specifically, I have been trying to click on an Anchor (a) element with a href tag, and despite trying various suggestions found in dif ...

Issue with Docker's depends_on flag not successfully handling dependencies between containers

My goal is to set up a Selenium hub, Chrome node, and Firefox node, and then run the test execution script in that specific order. I have the nodes depending on the hub, and the code depends on both the hubs. However, when I run docker-compose --build, it ...

What is the method in Python to utilize a range of numbers within a variable in an f-string, allowing them to be inserted and executed sequentially?

As a newcomer to the coding realm, I'm seeking some assistance with a Selenium and Python project. I've been unable to locate any useful resources thus far. Is it feasible to define variables in an f-string as a range of numbers that are then ins ...

Adding the current date and time to an Excel file

I am encountering a "java.io.FileNotFoundException:" exception when trying to run the code below. My goal is to add the current system date and time to an xlsx file. Can you help me identify the issue? String currentDate = new SimpleDateFormat("MM/dd/yy ...

Tips on how to use Selenium and Java to successfully click on the "logout" link in HTML

Below is the code snippet: <div id="user-tools"> Welcome <strong>Admin</strong> / <a href="/">View</a> / <a href="/admin/password_change">Change password</a> / </a href="/admin/l ...

Utilizing a blend of UI script and personalized server-side scripts to initiate automated testing through TestRail

Many teams opt to run their automated tests separately from TestRail, usually through a continuous integration system, while using TestRail's API to input the test results. However, I am interested in initiating automated tests directly from TestRail ...

Using JQuery to Give the TinyMCE Editor Focus: A Step-by-Step Guide

My current challenge involves adding text to the TinyMCE editor using SELENIUM. I have successfully added text with the following code snippet: $('iframe').last().contents().find('body').text('401c484b-68e4-4bf2-a13d-2a564acddc04& ...

Having issues with Chrome Driver timing out after 60 seconds despite using the --no-options flag

My automated task takes a long time to run and sometimes the webpage doesn't fully load for over a minute. I have attempted to set the default timeout in two different ways, but both methods are not working as expected. The error of default timeout af ...