-1

I have written a scenario to login to the application using cucumber framework. Initially I had written the code in eclipse and It run successfully, but when I copied the same code and dependencies the code is not at all working it is saying that the step is undefined.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Deepa
  • 561
  • 1
  • 5
  • 7

1 Answers1

-1

That shouldn't be an issue. Are you executing the tests from the root dir. what was the command your using to run the tests. mostly the directory path would be the issue. check and try the relative path to avoid such issues.

  • Thanks for the reply.. I am new to cucumber framework, I have worked on webdriver with testng. I just wrote code to launch the application. where we need to set the directory path.. And we can directly run the scenario rite? or TestRunner is must to run even sing scenarios. – Deepa May 11 '15 at 09:18
  • I guess the problem was with directories.. I just created a new directory and copies feature files and run the test it is working fine thanks Anvesh.. In cucumber how can we handle the returned value from the function in feature files. – Deepa May 11 '15 at 09:37
  • you should handle the data as part of your step definition keeping the objects visible globally, no need to pass back to the feature file. Given When Then – Anvesh Kumar May 11 '15 at 10:19
  • okie Thank you.. I have one more question.. I have written code to start browser in Before annotation and driver.close, driver.quit in After annotation.. in selenium webdriver using testNG framework, I used to extend that class so that before every test @Before method will run. Here we have feature file, how we can do this? – Deepa May 11 '15 at 10:33
  • yes its possible with the helps of hooks in cucumber refer to the below link for more details: https://github.com/cucumber/cucumber/wiki/Hooks – Anvesh Kumar May 11 '15 at 10:41
  • okay.. Hooks should be a class? In the above link they have given Hooks.rb, I think .rb belongs to ruby language.. and also they have mentioned that create Hooks.rb under directory, but we cannot create class under directory.. – Deepa May 11 '15 at 10:55
  • hmm it would have confused you with ruby implementation here is the java example reference https://github.com/ZsoltFabok/cucumber-jvm-post/blob/episode_6/src/test/java/com/zsoltfabok/blog/WebTextMungerStepsdef.java https://github.com/ZsoltFabok/cucumber-jvm-post/blob/episode_6/src/test/resources/web_text_munger.feature – Anvesh Kumar May 11 '15 at 11:01
  • ok Thank you very much.. I have written login method which accepts username and password as argument, and I have more than 6 types user. Here I can use the same login method for all user but I cannot hardcode the username and pswd in every scenario, and also we cannot read the class variable in feature file, solution for this problem will be saving the user details in excel and passing the column numbers accordingly. Is this the right way? – Deepa May 11 '15 at 11:08
  • yes that's the standard. You should keep the test data in .txt or csv. For faster processing of csv you can use jackson dataformat classes https://github.com/FasterXML/jackson-dataformat-csv – Anvesh Kumar May 11 '15 at 15:56