├── .gitignore
├── pom.xml
└── src
├── main
└── java
│ └── AmazonImplementation
│ ├── Product.java
│ └── Search.java
└── test
├── java
├── MyHooks
│ └── AmazonHooks.java
├── stepdefinitions
│ ├── AmazonHomePage.java
│ ├── AmazonLoginPage.java
│ ├── BillingSteps.java
│ ├── OrdersSteps.java
│ ├── SearchSteps.java
│ ├── UberBookingSteps.java
│ └── UserRegistrationSteps.java
└── testrunners
│ ├── AmazonTest.java
│ ├── BillingTest.java
│ ├── OrderTest.java
│ ├── UberTest.java
│ └── UserRegTest.java
└── resources
├── AppFeatures
├── AmazonHomePage.feature
├── AmazonLogin.feature
├── Order.feature
├── Search.feature
├── Uber.feature
├── billing.feature
├── login.feature
├── notes
└── registration.feature
└── cucumber.properties
/.gitignore:
--------------------------------------------------------------------------------
1 | allure-results/
2 | screenshots/
3 | test-output/
4 |
5 |
6 | ##############################
7 | ## Java
8 | ##############################
9 | .mtj.tmp/
10 | *.class
11 | *.jar
12 | *.war
13 | *.ear
14 | *.nar
15 | hs_err_pid*
16 | ##############################
17 | ## Maven
18 | ##############################
19 | target/
20 | pom.xml.tag
21 | pom.xml.releaseBackup
22 | pom.xml.versionsBackup
23 | pom.xml.next
24 | pom.xml.bak
25 | release.properties
26 | dependency-reduced-pom.xml
27 | buildNumber.properties
28 | .mvn/timing.properties
29 | .mvn/wrapper/maven-wrapper.jar
30 |
31 | ##############################
32 | ## IntelliJ
33 | ##############################
34 | out/
35 | .idea/
36 | .idea_modules/
37 | *.iml
38 | *.ipr
39 | *.iws
40 | ##############################
41 | ## Eclipse
42 | ##############################
43 | .settings/
44 | bin/
45 | tmp/
46 | .metadata
47 | .classpath
48 | .project
49 | *.tmp
50 | *.bak
51 | *.swp
52 | *~.nib
53 | local.properties
54 | .loadpath
55 | .factorypath
56 |
57 | ## OS X
58 | ##############################
59 | .DS_Store
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | CucumberYouTubeSeries
9 | CucumberPractices
10 | 0.0.1-SNAPSHOT
11 |
12 | CucumberPractices
13 |
14 | http://www.example.com
15 |
16 |
17 | UTF-8
18 | 1.8
19 | 4.13.1
20 | 6.9.0
21 | 3.8.1
22 | 2.22.2
23 |
24 |
25 |
26 |
27 | io.cucumber
28 | cucumber-java
29 | ${cucumber.version}
30 | test
31 |
32 |
33 |
34 | io.cucumber
35 | cucumber-junit
36 | ${cucumber.version}
37 | test
38 |
39 |
40 |
41 | junit
42 | junit
43 | ${junit.version}
44 | test
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.apache.maven.plugins
55 | maven-compiler-plugin
56 | ${maven.compiler.version}
57 |
58 | UTF-8
59 | ${java.version}
60 | ${java.version}
61 |
62 |
63 |
64 | org.apache.maven.plugins
65 | maven-surefire-plugin
66 | ${maven.surefire.version}
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/main/java/AmazonImplementation/Product.java:
--------------------------------------------------------------------------------
1 | package AmazonImplementation;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Product {
7 |
8 | private String productName;
9 | private int price;
10 |
11 | public Product(String productName, int price) {
12 | this.productName = productName;
13 | this.price = price;
14 | }
15 |
16 | public String getProductName() {
17 | return productName;
18 | }
19 |
20 | public void setProductName(String productName) {
21 | this.productName = productName;
22 | }
23 |
24 | public int getPrice() {
25 | return price;
26 | }
27 |
28 | public void setPrice(int price) {
29 | this.price = price;
30 | }
31 |
32 | public List getProductList() {
33 | List productList = new ArrayList<>();
34 | productList.add("Apple MacBook Pro");
35 | productList.add("Apple MacBook Air");
36 | productList.add("Apple iPhone 12");
37 | return productList;
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/AmazonImplementation/Search.java:
--------------------------------------------------------------------------------
1 | package AmazonImplementation;
2 |
3 | public class Search {
4 |
5 | public String displayProduct(Product product) {
6 |
7 | if (product.getProductList().contains(product.getProductName())) {
8 | return product.getProductName();
9 | }
10 | return null;
11 |
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/java/MyHooks/AmazonHooks.java:
--------------------------------------------------------------------------------
1 | package MyHooks;
2 |
3 | import io.cucumber.java.After;
4 | import io.cucumber.java.Before;
5 | import io.cucumber.java.Scenario;
6 |
7 | public class AmazonHooks {
8 |
9 |
10 | // @Before("@Smoke")
11 | // public void setup_browser(Scenario sc) {
12 | // System.out.println("launch chrome browser");
13 | // System.out.println(sc.getName());
14 | //
15 | // }
16 | //
17 | // @Before(order = 2)
18 | // public void setup_url() {
19 | // System.out.println("launch url");
20 | // }
21 | //
22 | // @After(order = 2)
23 | // public void tearDown_close(Scenario sc) {
24 | // System.out.println("close the browser");
25 | // System.out.println(sc.getName());
26 | // }
27 | //
28 | // @After("@Smoke")
29 | // public void tearDown_logout() {
30 | // System.out.println("logout from application");
31 | // }
32 |
33 |
34 | // @BeforeStep()
35 | // public void takescreenshot() {
36 | // System.out.println("take the screenshot");
37 | // }
38 | //
39 | // @AfterStep
40 | // public void refreshPage() {
41 | // System.out.println("refresh the page");
42 | // }
43 |
44 |
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/AmazonHomePage.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import java.util.List;
4 |
5 | import io.cucumber.datatable.DataTable;
6 | import io.cucumber.java.en.Given;
7 | import io.cucumber.java.en.Then;
8 | import io.cucumber.java.en.When;
9 |
10 | public class AmazonHomePage {
11 |
12 | @Given("user is on Amazon home page")
13 | public void user_is_on_amazon_home_page() {
14 |
15 | }
16 |
17 | @Then("user gets a Amazon search field")
18 | public void user_gets_a_amazon_search_field() {
19 | }
20 |
21 | @Then("username is also displayed next to search field")
22 | public void username_is_also_displayed_next_to_search_field() {
23 | }
24 |
25 | @Then("Amazon logo is also displayed")
26 | public void amazon_logo_is_also_displayed() {
27 |
28 |
29 | }
30 |
31 | @Then("Cart link is also displayed")
32 | public void cart_link_is_also_displayed() {
33 | }
34 |
35 | @When("user scrolls down to Todays Deals section")
36 | public void user_scrolls_down_to_todays_deals_section() {
37 | }
38 |
39 | @Then("user gets the list of multiple products")
40 | public void user_gets_the_list_of_multiple_products() {
41 | }
42 |
43 | @Then("user gets product image and price details")
44 | public void user_gets_product_image_and_price_details() {
45 | }
46 |
47 | @Then("user can see more products by clicking on carousel")
48 | public void user_can_see_more_products_by_clicking_on_carousel() {
49 | }
50 |
51 | @When("user scrolls down to footer of the page")
52 | public void user_scrolls_down_to_footer_of_the_page() {
53 | }
54 |
55 | @Then("user gets all Country links")
56 | public void user_gets_all_country_links(DataTable dataTable) {
57 |
58 | List> countryList = dataTable.asLists();
59 | System.out.println(countryList);
60 | }
61 |
62 | @Then("user gets all amazon services links")
63 | public void user_gets_all_amazon_services_links(DataTable dataTable) {
64 | List> servicesList = dataTable.asLists();
65 | System.out.println(servicesList);
66 |
67 | }
68 |
69 | @Then("User gets all privacy policy links")
70 | public void user_gets_all_privacy_policy_links(DataTable dataTable) {
71 | List> policyList = dataTable.asLists();
72 | System.out.println(policyList);
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/AmazonLoginPage.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import io.cucumber.java.en.Given;
4 | import io.cucumber.java.en.Then;
5 | import io.cucumber.java.en.When;
6 |
7 | public class AmazonLoginPage {
8 |
9 |
10 | @Given("user is on Amazon landing page")
11 | public void user_is_on_amazon_landing_page() {
12 | // Write code here that turns the phrase above into concrete actions
13 | throw new io.cucumber.java.PendingException();
14 | }
15 |
16 | @Given("Sign in button is present on screen")
17 | public void sign_in_button_is_present_on_screen() {
18 | // Write code here that turns the phrase above into concrete actions
19 | throw new io.cucumber.java.PendingException();
20 | }
21 |
22 | @When("user clicks on Sign in button")
23 | public void user_clicks_on_sign_in_button() {
24 | // Write code here that turns the phrase above into concrete actions
25 | throw new io.cucumber.java.PendingException();
26 | }
27 |
28 | @Then("user is displayed login screen")
29 | public void user_is_displayed_login_screen() {
30 | // Write code here that turns the phrase above into concrete actions
31 | throw new io.cucumber.java.PendingException();
32 | }
33 |
34 | @When("user enters {string} in username field")
35 | public void user_enters_in_username_field(String string) {
36 | // Write code here that turns the phrase above into concrete actions
37 | throw new io.cucumber.java.PendingException();
38 | }
39 |
40 | @When("user enters {string} in password field")
41 | public void user_enters_in_password_field(String string) {
42 | // Write code here that turns the phrase above into concrete actions
43 | throw new io.cucumber.java.PendingException();
44 | }
45 |
46 | @When("user clicks Sign in button")
47 | public void user_clicks_sign_in_button() {
48 | // Write code here that turns the phrase above into concrete actions
49 | throw new io.cucumber.java.PendingException();
50 | }
51 |
52 | @Then("user is on home page")
53 | public void user_is_on_home_page() {
54 | // Write code here that turns the phrase above into concrete actions
55 | throw new io.cucumber.java.PendingException();
56 | }
57 |
58 | @Then("title of home page is {string}")
59 | public void title_of_home_page_is(String string) {
60 | // Write code here that turns the phrase above into concrete actions
61 | throw new io.cucumber.java.PendingException();
62 | }
63 |
64 | @Then("Sign in button is not present")
65 | public void sign_in_button_is_not_present() {
66 | // Write code here that turns the phrase above into concrete actions
67 | throw new io.cucumber.java.PendingException();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/BillingSteps.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import org.junit.Assert;
4 |
5 | import io.cucumber.datatable.DataTable;
6 | import io.cucumber.java.en.Given;
7 | import io.cucumber.java.en.Then;
8 | import io.cucumber.java.en.When;
9 |
10 | public class BillingSteps {
11 |
12 | double billingAmount;
13 | double taxAmount;
14 | double finalAmount;
15 |
16 | @Given("user is on billing page")
17 | public void user_is_on_billing_page() {
18 | }
19 |
20 | @When("user enters billing amount {string}")
21 | public void user_enters_billing_amount(String billingAmount) {
22 | this.billingAmount = Double.parseDouble(billingAmount);
23 | }
24 |
25 |
26 | @When("user enters tax amount {string}")
27 | public void user_enters_tax_amount(String taxAmount) {
28 | this.taxAmount = Double.parseDouble(taxAmount);
29 | }
30 |
31 | @When("user clicks on calculate button")
32 | public void user_clicks_on_calculate_button() {
33 | }
34 |
35 | @Then("it gives the final amount {string}")
36 | public void it_gives_the_final_amount(String expectedFinalAmount) {
37 | this.finalAmount = this.billingAmount + this.taxAmount;
38 | System.out.println("expected final amount: " + Double.parseDouble(expectedFinalAmount));
39 | System.out.println("actual final amount: " + this.finalAmount);
40 |
41 | Assert.assertTrue(this.finalAmount == Double.parseDouble(expectedFinalAmount));
42 | }
43 |
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/OrdersSteps.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import io.cucumber.java.en.Given;
4 | import io.cucumber.java.en.Then;
5 | import io.cucumber.java.en.When;
6 |
7 | public class OrdersSteps {
8 |
9 | @Given("a registered user exists")
10 | public void a_registered_user_exists() {
11 |
12 | }
13 |
14 | @Given("user is on Amazon login page")
15 | public void user_is_on_amazon_login_page() {
16 | }
17 |
18 | @When("user enters username")
19 | public void user_enters_username() {
20 | }
21 |
22 | @When("user enters password")
23 | public void user_enters_password() {
24 | }
25 |
26 | @When("user clicks on login button")
27 | public void user_clicks_on_login_button() {
28 | }
29 |
30 | @Then("user navigates to order page")
31 | public void user_navigates_to_order_page() {
32 | }
33 |
34 | @When("user clicks on Order link")
35 | public void user_clicks_on_order_link() {
36 | }
37 |
38 | @Then("user checks the previous order detials")
39 | public void user_checks_the_previous_order_detials() {
40 | }
41 |
42 | @When("user clicks on Open Orders link")
43 | public void user_clicks_on_open_orders_link() {
44 | }
45 |
46 | @Then("user checks the open order details")
47 | public void user_checks_the_open_order_details() {
48 | }
49 |
50 | @When("user clicks on Cancelled Orders link")
51 | public void user_clicks_on_cancelled_orders_link() {
52 | }
53 |
54 | @Then("user checks the cancelled order details")
55 | public void user_checks_the_cancelled_order_details() {
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/SearchSteps.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import AmazonImplementation.Product;
4 | import AmazonImplementation.Search;
5 | import io.cucumber.java.en.Given;
6 | import io.cucumber.java.en.Then;
7 | import io.cucumber.java.en.When;
8 | import junit.framework.Assert;
9 |
10 | public class SearchSteps {
11 |
12 | Product product;
13 | Search search;
14 |
15 | @Given("I have a search field on Amazon Page")
16 | public void i_have_a_search_field_on_amazon_page() {
17 | System.out.println("Step 1: I am on search page");
18 | }
19 |
20 | @When("^I search for a product with name \"([^\"]+)\" and price (\\d+)$")
21 | public void i_search_for_a_product_with_name_and_price(String productName, Integer price) {
22 | System.out.println("Step 2: Search the product with name : " + productName + " price: " + price);
23 | product = new Product(productName, price);
24 | }
25 |
26 | @Then("Product with name {string} should be displayed")
27 | public void product_with_name_should_be_displayed(String productName) {
28 | System.out.println("Step 3: product " + productName + " is displayed");
29 |
30 | search = new Search();
31 | String name = search.displayProduct(product);
32 | System.out.println("searched product is : " + name);
33 |
34 | }
35 |
36 | @Then("Order id is {int} and username is {string}")
37 | public void order_id_is_and_username_is(Integer int1, String string) {
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/UberBookingSteps.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import io.cucumber.java.en.Given;
4 | import io.cucumber.java.en.Then;
5 | import io.cucumber.java.en.When;
6 |
7 | public class UberBookingSteps {
8 |
9 | @Given("User wants to select a car type {string} from uber application")
10 | public void user_wants_to_select_a_car_type_from_uber_app(String carType) {
11 | System.out.println("step 1 : " + carType);
12 | }
13 |
14 | @When("User selects car {string} and pick up point {string} and drop location {string}")
15 | public void user_selects_car_and_pick_up_point_and_drop_location(String carType, String pickUpLocation,
16 | String DropLocation) {
17 | System.out.println("step 2 : " + carType + " " + pickUpLocation + " " + DropLocation);
18 | }
19 |
20 | @Then("Driver starts the journey")
21 | public void driver_starts_the_journey() {
22 | System.out.println("step 3");
23 |
24 | }
25 |
26 | @Then("Driver ends the journey")
27 | public void driver_ends_the_journey() {
28 | System.out.println("step 4");
29 |
30 | }
31 |
32 | @Then("User pays {int} USD")
33 | public void user_pays_usd(Integer price) {
34 | System.out.println("step 5 : " + price);
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/stepdefinitions/UserRegistrationSteps.java:
--------------------------------------------------------------------------------
1 | package stepdefinitions;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import io.cucumber.datatable.DataTable;
7 | import io.cucumber.java.en.Given;
8 | import io.cucumber.java.en.Then;
9 | import io.cucumber.java.en.When;
10 |
11 | public class UserRegistrationSteps {
12 |
13 | @Given("User is on registration page")
14 | public void user_is_on_registration_page() {
15 |
16 | System.out.println("user navigates on registration page");
17 | }
18 |
19 | @When("User enters following user details")
20 | public void user_enters_following_user_details(DataTable dataTable) {
21 |
22 | List> userList = dataTable.asLists(String.class);
23 |
24 | for (List e : userList) {
25 | System.out.println(e);
26 | }
27 | }
28 |
29 | @When("User enters following user details with columns")
30 | public void user_enters_following_user_details_with_columns(DataTable dataTable) {
31 | List