In this three part video sessions, I have explained how to create the new feature file and their respective step definitions.
Framework is kept at this Git Hub Location:
https://github.com/akashdktyagi/AutomationPoCCucumber
Please refer the previous part of this cucumber tutorial first for better understanding.(follow below link), In previous session I have given a walk through of the framework structure and base functionalities.
Other Important session is on Git usage. Please have a look at below as well to perform Git clone and fetch of latest framework features in your local copy of the framework.
Framework Development Part 4-All about Git and how to use Git in a Live Team Set Up
Code Components for this Framework:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
@cscart Feature: Check the Search Functionality for multiple products Iterate Search for multiple products @cscart_search Scenario Outline: Search multiple products from feature file Given As a user when I launch application in "chrome" And navigate to url as "https://demo.cs-cart.com" When I enter "<Product>" in top search box And click on search submit button Then page navigates to product search results And proudct results are displayed And close the browser Examples: | Product | | Computer | | Mobile | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
package bddcucumber.ecommerce.stepdefs; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.PageFactory; import bddcucumber.ecommerce.po.*; import bddcucumber.managers.WebDriverManagerSingleton; import cucumber.api.Scenario; import cucumber.api.java.Before; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import junit.framework.Assert; public class STEPS_CsCartHomeSearch { WebDriverManagerSingleton browserManager = WebDriverManagerSingleton.getInstanceOfWebDriverManager(); WebDriver driver = browserManager.getDriver(); PO_Header PO_Header = PageFactory.initElements(driver, PO_Header.class); PO_Search PO_Search = PageFactory.initElements(driver, PO_Search.class); Scenario scn ; @Before public void SetUp(Scenario s) { this.scn = s; } @When("I enter {string} in top search box") public void i_enter_product_in_top_search_box(String productname) { PO_Header.SetSearchBox(productname); scn.write("Product entered in the Search box: " + productname); } @When("click on search submit button") public void click_on_search_submit_button() { PO_Header.ClickSearchSumitButton(); scn.write("Clicked on Search Button"); } @Then("page navigates to product search results") public void page_navigates_to_product_search_results() { String expected = "Search results"; String actual = driver.getTitle(); Assert.assertEquals(expected, actual); scn.write("validation of the page title is successfull"); } @Then("proudct results are displayed") public void proudct_results_are_displayed() { scn.write("validating the Search results"); PO_Search.validate_search_results(); scn.write("validation of the Search results is successfull"); } } |