Error – Test class not found in selected project in cucumber

I am new to cucumber. I followed your whole cucumber tutorial step by step. I f I run the selenium test it runs successfully. But When I run TestRunner class, it shows this error for Login Functionality, when double clicked.

For code, its same whats on your website. Please help …

Error - Test class not found in selected project in cucumber

Add Comment
  • 4 Answer(s)

    The element that you are trying to locate has invalid xpath. Can you recheck the xpath of the element and use the correct one. Try firebug to find the xpath. Here is the tutorial

    Professor Answered on January 5, 2016.
    Add Comment

    Thanks virender for your reply.

    The reason this error is coming is : there is no login page.

    According to the code for cucumber tutorial, first my account button should be clicked, the login credentials should be entered and then after successful login you should logout.

    Now If I run selenium test this functionality is working. But with test runner class……. it is just opening the demo website in browser, not clicking on it.
    And it is directly going to the logout scenario. That y the error is there, as there is no logout button on the browser.

    So, my problem is why it is not entering into Given scenario.


    Train Answered on January 5, 2016.
    Add Comment

    It seems that you are missing a step in step definition file. Can you please do two things
    – Share the feature file and the step definitions
    – Point me to the tutorial URL from where you have picked this up on ToolsQA. I will try to reproduce it.


    Professor Answered on January 6, 2016.
    Add Comment


    Please find below the codes for festures file , step definition & test runner file.

    feature file

    Feature: Login Action
    Scenario: Successful Login with Valid Credentials
    Given User is on Home Page
    When User Navigate to LogIn Page
    And User enters UserName and Password
    Then Message displayed Login Successfully
    Scenario: Successful LogOut
    When User LogOut from the Application
    Then Message displayed LogOut Successfully

    Step Definition

    package stepDefinition;
    import java.util.concurrent.TimeUnit;
    import org.junit.rules.Timeout;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import cucumber.api.PendingException;
    public class Test_Steps
    public static WebDriver driver;
    @Given("^User is on Home Page$")
    public void user_is_on_Home_Page() throws Throwable
    driver = new FirefoxDriver();
    throw new PendingException();
    @When("^User Navigate to LogIn Page$")
    public void user_Navigate_to_LogIn_Page() throws Throwable
    throw new PendingException();
    @When("^User enters UserName and Password$")
    public void user_enters_UserName_and_Password() throws Throwable
    throw new PendingException();
    @Then("^Message displayed Login Successfully$")
    public void message_displayed_Login_Successfully() throws Throwable
    System.out.println("Login Successfully");
    throw new PendingException();
    @When("^User LogOut from the Application$")
    public void user_LogOut_from_the_Application() throws Throwable
    driver.findElement (By.xpath(".//*[@id='account_logout']/a")).click();
    throw new PendingException();
    @Then("^Message displayed LogOut Successfully$")
    public void message_displayed_LogOut_Successfully() throws Throwable
    System.out.println("LogOut Successfully");
    throw new PendingException();

    Test Runner

    package cucumberTest;
    import org.junit.runner.RunWith;
    import cucumber.api.CucumberOptions;
    import cucumber.api.junit.Cucumber;
    features = "Feature",
    glue = {"stepDefinition"}
    public class TestRunner {

    Below hers is the link :


    Train Answered on January 11, 2016.


    I am also facing the same issue. Please let me know the solution.


    Thanks and Regards,

    Tanuja N

    on June 5, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.