Cucumber - Missing steps

170 views
Skip to first unread message

Shanthi Kandasamy

unread,
Oct 29, 2019, 2:04:54 AM10/29/19
to Selenium Users
Hi All,

Even after mapping all the steps from feature to stepdefiniton I still get
"You can implement missing steps with the snippets below:" and it shows all the steps I've written in feature file - any advice from anyone?

Regards
Shanthi

Joe Ward

unread,
Oct 29, 2019, 3:09:50 AM10/29/19
to seleniu...@googlegroups.com
Not really a Selenium question but it sounds like you aren’t telling the test runner where to look for the glue code. 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1a35e13a-c73a-4730-b17f-6450924639b3%40googlegroups.com.

Imran Khan

unread,
Oct 29, 2019, 3:19:02 AM10/29/19
to seleniu...@googlegroups.com
Hi Shanthi,

Use the @Runwith(Cucumber.class) with feature and glue code.

After that, go to your feature file then do the recalculate steps.

Hope this helps.

Thanks,
Imran.

--

Shanthi Kandasamy

unread,
Oct 29, 2019, 3:40:49 AM10/29/19
to seleniu...@googlegroups.com
Hi Imran ,

I have clearly mentioned those cucumber options(features and glue) but yet getting what I mentioned in my first mail

Imran Khan

unread,
Oct 29, 2019, 3:45:08 AM10/29/19
to seleniu...@googlegroups.com
Hi Shanthi,

Can you please share your code here, if it is possible? 

Thanks,
Imran.

Shanthi Kandasamy

unread,
Oct 29, 2019, 9:18:56 AM10/29/19
to seleniu...@googlegroups.com
Hey Imran,

Please take a look at my code , I defined the locators in src/main/java using @FindBy

Feature
Feature: Welcome To the Internet

Scenario: Available Examples

Given User should be on the home page
Then click on to Add/Remove Elements
Then click on Add Elements
Then Click on Delete And Navigate back

Runner
package Runner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature",
         glue = "SDefinition",
         format= {"pretty","html:test-outout"},
         monochrome = true,
         dryRun = true
         )
public class TestRunner {

}

StepDefinition
package SDefinition;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import Resources.FirstPageLocator;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;

public class StepDefinition_FP {
FirstPageLocator fpl = new FirstPageLocator();
WebDriver driver;
@Given("^User should be on the home page$")
public void user_should_be_on_the_home_page() {
System.setProperty("webdriver.gecko.driver","C:\\Users\\Shanthi\\Downloads\\geckodriver-master\\geckodriver.exe");
 driver = new FirefoxDriver() ;
 driver.get("http://the-internet.herokuapp.com/");
   
}

@Then("^click on to Add/Remove Elements$")
public void click_on_to_Add_Remove_Elements()  {
    fpl.addB().click();
}

@Then("^click on Add Elements$")
public void click_on_Add_Elements()  {
  fpl.addeleB().click();
 
}

@Then("^Click on Delete And Navigate back$")
public void click_on_Delete_And_Navigate_back()  {
  fpl.deleleB().click();
  driver.navigate().back();
   
}


}

Joe Ward

unread,
Oct 29, 2019, 10:16:57 AM10/29/19
to seleniu...@googlegroups.com
You need to provide a path to your features and the packages to where your glue code can be found.

Shanthi Kandasamy

unread,
Oct 29, 2019, 11:49:14 AM10/29/19
to seleniu...@googlegroups.com
Folder name should also help..anyways I changed as you said but getting below error

Error: Initialization error(This is what it says nothing else)
Runner:

@RunWith(Cucumber.class)
@CucumberOptions(
features = "/BDDFrameWork/src/test/java/Feature/FirstPage.feature",
         glue = "/BDDFrameWork/src/test/java/SDefinition/StepDefinition_FP.java",

         format= {"pretty","html:test-outout"},
         monochrome = true,
         dryRun = true
         )
public class TestRunner {

thilana Athi

unread,
Oct 29, 2019, 11:58:30 AM10/29/19
to seleniu...@googlegroups.com
Initialisation error used to come when there is mismatch in pipeline symbol(|) in the examples section of feature file.make sure it's properly formatted

Joe Ward

unread,
Oct 29, 2019, 12:00:23 PM10/29/19
to seleniu...@googlegroups.com
features = "/BDDFrameWork/src/test/java/Feature/FirstPage.feature",
this should probably look like
features = "./src/test/java/Feature/",

Joe Ward

unread,
Oct 29, 2019, 12:01:14 PM10/29/19
to seleniu...@googlegroups.com
Sorry, I just noticed:

glue = "/BDDFrameWork/src/test/java/SDefinition/StepDefinition_FP.java",

This is a path, not a package. You must supply a package e.g. "com.whatever".

Imran Khan

unread,
Oct 29, 2019, 12:30:22 PM10/29/19
to seleniu...@googlegroups.com
Shanthi,

Use the whole package name of your step definition file. Don't give the path.

Something like this,

"StepDefinition" - that's all.

Reply all
Reply to author
Forward
0 new messages