When the "Given" parameter is called, the state must be set and a Then they must make statements on the content. Your assignment is poorly constructed because it is about asserting what is on the page. You must rewrite it to describe WHAT you need to do to make sure that you can see a specific element.
For example, if your assignment matches
Given "element with id 'product_foo' is displayed"
This script should be revised in a read script.
Given 'there is a product foo'
Actually, you cannot implement Given("^element with id \"([^\"]*)\" is displayed$") for general use even in a small application, because it will need to know how to create everything that can be displayed in your application in any context. You can see the product_foo id on the product page, or when it was ordered, or in your basket. The first just requires the product, the second requires the previous order, and the third requires a session with the product in the basket.
source share