88import io .cucumber .java .en .When ;
99import org .openqa .selenium .By ;
1010import org .openqa .selenium .support .PageFactory ;
11- import pages .CartPage ;
12- import pages .InventoryPage ;
13- import pages .LoginPage ;
14- import pages .MenuPopUP ;
11+ import pages .*;
1512
1613import java .util .List ;
1714import java .util .Map ;
@@ -24,12 +21,15 @@ public class SauceDemoSteps {
2421 private final MenuPopUP menuPopUP ;
2522 private final CartPage sauceDemoCartPage ;
2623
24+ private final CheckoutStepOnePage sauceDemoCheckoutStepOncePage ;
25+
2726 public SauceDemoSteps () {
2827
2928 sauceDemoLoginPage = PageFactory .initElements (driver , LoginPage .class );
3029 sauceDemoInventoryPage = PageFactory .initElements (driver , InventoryPage .class );
3130 menuPopUP = PageFactory .initElements (driver , MenuPopUP .class );
32- sauceDemoCartPage = PageFactory .initElements (driver ,CartPage .class );
31+ sauceDemoCartPage = PageFactory .initElements (driver , CartPage .class );
32+ sauceDemoCheckoutStepOncePage = PageFactory .initElements (driver , CheckoutStepOnePage .class );
3333 }
3434
3535 @ Given ("^I login with \" ([^\" ]*)\" $" )
@@ -77,6 +77,50 @@ public void i_logout_the_web() {
7777 menuPopUP .logout ();
7878 }
7979
80+
81+ @ And ("^I proceed to checkout" )
82+ public void i_proceed_checkout () {
83+ driver .findElement (By .cssSelector ("[data-test='checkout']" )).click ();
84+ }
85+
86+
87+ @ When ("I fill checkout form with first name {string}, last name {string}, zip code {string}" )
88+ public void i_fill_checkout_form (String first , String last , String zip ) {
89+ sauceDemoCheckoutStepOncePage .fillCustomerInfo (first , last , zip );
90+ }
91+
92+ @ And ("I {string} the checkout process" )
93+ public void i_choose_action (String action ) {
94+ if (action .equalsIgnoreCase ("continue" )) {
95+ sauceDemoCheckoutStepOncePage .continueCheckout ();
96+ } else if (action .equalsIgnoreCase ("cancel" )) {
97+ sauceDemoCheckoutStepOncePage .cancelCheckout ();
98+ } else {
99+ throw new IllegalArgumentException ("Unknown action: " + action );
100+ }
101+ driver .quit ();
102+ }
103+
104+ @ Given ("I am on the checkout step one page" )
105+ public void i_am_on_checkout_step_one () {
106+
107+ }
108+
109+ @ Given ("I am on the checkout step two page" )
110+ public void i_am_on_checkout_step_two () {
111+
112+ }
113+
114+ @ Given ("I am on the inventory page" )
115+ public void i_am_on_inventory () {
116+
117+ }
118+
119+ @ Given ("I am on the cart page" )
120+ public void i_am_on_cart () {
121+
122+ }
123+
80124 @ When ("I view the cart" )
81125 public void i_view_the_Cart () {
82126 driver .findElement (By .cssSelector ("span[data-test='shopping-cart-badge']" )).click ();
0 commit comments