RE: 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 …

RE: Error - Test class not found in selected project in cucumber

Add Comment
4 Answers

Virender,

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;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.When;
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();

driver.manage().window().maximize();

driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

driver.get("http://www.store.demoqa.com");

throw new PendingException();

}
@When("^User Navigate to LogIn Page$")

public void user_Navigate_to_LogIn_Page() throws Throwable

{

driver.findElement(By.xpath(".//*[@id='account']/a")).click();

throw new PendingException();

}
@When("^User enters UserName and Password$")

public void user_enters_UserName_and_Password() throws Throwable

{

driver.findElement(By.id("log")).sendKeys("abcdefg");

driver.findElement(By.id("pwd")).sendKeys("123456789");

driver.findElement(By.id("login")).click();

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");

driver.close();

throw new PendingException();

}

}


Test Runner

package cucumberTest;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)

@CucumberOptions(

features = "Feature",

glue = {"stepDefinition"}

)
public class TestRunner {
}

Below hers is the link :

http://toolsqa.com/cucumber/first-cucumber-selenium-java-test/

Thanks,
Manasi

Train Answered on January 11, 2016.

Hi,

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.