In the previous tutorial we learned about writing the scenarios and steps in the feature file. Also we seen that steps being highlighted in yellow color since they do not have step definitions. Now we will learn writing the step definitions.
I will be taking only one scenario for simplicity. You can follow same approach for remaining scenarios.
Step 1: Create a package say 'cucumberStepsDefinion' as shown below.
Copy the path of the 'cucumberStepsDefinion' package.
Step 2: Keep the cursor on the any step and press 'Alt+ENTER', you will get a pop up with two options 'Create Step Definition' and 'Create All Step Definitions'.
Step 3: Select 'Create Step Definition' (anyways 'Create All Step Definitions' is not working in the first attempt), then paste 'cucumberStepsDefinition' package file path in File location and enter 'StepDefinitions' class name. Click on 'OK' button.
You should see step definition being created in the newly created 'StepDefinitions.java' file as below
Step 4: For remaining steps place cursor and press 'Alt+ENTER', this time select 'Create steps definition' and IntelliJ will asks you to choose 'Create new file' or existing 'StepDefinitions' file. Select 'StepDefinitions'
Now you should see all the step definitions being added to the 'StepDefinitions.java' file as below
Step 5: Right Click on the 'gmailLoginFeature.feature' and Run 'Feature:gmailLoginFeature'. When you do this we get something like below in the console
,
Even though we defined the step definitions we are getting 'Undefined steps' in the console. The reason is, we have not mapped our steps from feature file with step definitions.
Step 6: To map them, click on the Edit Configuration in IntelliJ
Step 7: Then select 'Cucumber java' in the left pane, and in the right pane provide 'cucumberStepsDefinition' package name in the 'Glue' field, Features folder location in 'folder path'
Click 'Apply' and 'OK'.
Step 8: Now run the 'gmailLoginFeature.feature' gain, this time you will see something like below (ignore the exception that doesn't matter) which means steps and step definitions are glued (mapped)
Step 9: Delete the existing or default content in the step definitions and write the respective actions that each step has to perform in their step definitions as below
We are not going to discuss selenium code here, you should be having basic idea selenium. This tutorial concentration is how to implement Cucumber in Selenium Automation.
We completed writing the step definitions as well. I tried my best make it more understandable with all the screenshots. The next part is run the tests using Junit runner class. We will see that in the next part.
Thanks for reading. #seleniumbabu #HappyLearning
I will be taking only one scenario for simplicity. You can follow same approach for remaining scenarios.
Step 1: Create a package say 'cucumberStepsDefinion' as shown below.
Copy the path of the 'cucumberStepsDefinion' package.
Step 2: Keep the cursor on the any step and press 'Alt+ENTER', you will get a pop up with two options 'Create Step Definition' and 'Create All Step Definitions'.
Step 3: Select 'Create Step Definition' (anyways 'Create All Step Definitions' is not working in the first attempt), then paste 'cucumberStepsDefinition' package file path in File location and enter 'StepDefinitions' class name. Click on 'OK' button.
You should see step definition being created in the newly created 'StepDefinitions.java' file as below
Step 4: For remaining steps place cursor and press 'Alt+ENTER', this time select 'Create steps definition' and IntelliJ will asks you to choose 'Create new file' or existing 'StepDefinitions' file. Select 'StepDefinitions'
Now you should see all the step definitions being added to the 'StepDefinitions.java' file as below
Step 5: Right Click on the 'gmailLoginFeature.feature' and Run 'Feature:gmailLoginFeature'. When you do this we get something like below in the console
,
Even though we defined the step definitions we are getting 'Undefined steps' in the console. The reason is, we have not mapped our steps from feature file with step definitions.
Step 6: To map them, click on the Edit Configuration in IntelliJ
Step 7: Then select 'Cucumber java' in the left pane, and in the right pane provide 'cucumberStepsDefinition' package name in the 'Glue' field, Features folder location in 'folder path'
Click 'Apply' and 'OK'.
Step 8: Now run the 'gmailLoginFeature.feature' gain, this time you will see something like below (ignore the exception that doesn't matter) which means steps and step definitions are glued (mapped)
Step 9: Delete the existing or default content in the step definitions and write the respective actions that each step has to perform in their step definitions as below
We are not going to discuss selenium code here, you should be having basic idea selenium. This tutorial concentration is how to implement Cucumber in Selenium Automation.
We completed writing the step definitions as well. I tried my best make it more understandable with all the screenshots. The next part is run the tests using Junit runner class. We will see that in the next part.
Thanks for reading. #seleniumbabu #HappyLearning
Best and unique information from you on the concept of selenium automation testing. Keep updating more info on Selenium.
ReplyDeleteselenium testing training in chennai | Best selenium training in chennai
Use your education as your most marketable asset. If you're an entry-level candidate with minimal professional experience, your education is your ticket. Coursework Writing Service
ReplyDelete
ReplyDeleteWonderful post!!Thank you for sharing this info with us.
Keep updating I would like to know more updates on this topic
Very useful content, I would like to suggest this blog to my friends.
software testing selenium training
Selenium Training in Chennai
ReplyDeleteI found so many interesting stuff in your blog especially writing steps for the improvements of dissertation writing service
. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work
I am hoping the same best effort from you in the future as well. In fact your creative writing skills has inspired me. write essays for money
ReplyDeleteIt is also possible to predict winners in a match using big data analytics. Future performance of players could be predicted as well.
ReplyDeleteangular js training in chennai
angular js training in tambaram
full stack training in chennai
full stack training in tambaram
php training in chennai
php training in tambaram
photoshop training in chennai
photoshop training in tambaram
Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
ReplyDeleteoracle training in chennai
oracle training in omr
oracle dba training in chennai
oracle dba training in omr
ccna training in chennai
ccna training in omr
seo training in chennai
seo training in omr