BDD with PageObject

Extract findElementBy and ClickElementBy in steps into meaningful methods

We can see findElementBy and ClickElementBy are called directly in steps, it's better to give them meaningful names:

And /^I add the first book to Wish List$/ do
    getCurrentItemTitle
    clickElementBy("id","add-to-wishlist-button-submit")
end

And /^I add the first book to shopping cart from Wish List$/ do clickElementBy("class","w-button-inner") addToShoppingCartFromWishList end

And /^I open my shopping cart$/ do clickElementBy("id","nav-cart") end

So we can extract them into methods:

And /^I add the first book to Wish List$/ do
    getCurrentItemTitle
    addToWishList
end

And /^I add the first book to shopping cart from Wish List$/ do openWishList addToShoppingCartFromWishList end

And /^I open my shopping cart$/ do openShoppingCart end

def addToWishList clickElementBy("id","add-to-wishlist-button-submit") end

def openWishList clickElementBy("class","w-button-inner") end

def openShoppingCart clickElementBy("id","nav-cart") end

alt text

alt text