title: How do we implement the 'Given' in a Gherkin Scenario (SpecFlow/BDD/Selenium)?
body: <p>We are applying BDD and using SpecFlow and Selenium. Acceptance criteria are specified in Gherkin. </p>
  
  <p>I have a question regarding the Given clause.</p>
  
  <p>An example might be...</p>
  
  <ul>
  <li>Given I am on the order details page </li>
  <li>When I submit the order </li>
  <li>Then I see the order summary</li>
  </ul>
  
  <p>So for the 'Given I am on the order details page' we have to be logged in and have an order ready to submit. But how do we get to that point?</p>
  
  <p>If we already have the relevant existing SpecFlow steps we can use these (via Selenium) to get to the right point - something like this...</p>
  
  <ul>
  <li>Given I am a registered user </li>
  <li>And I am on the login page </li>
  <li>And I log in using my registered username and password </li>
  <li>And I create a new order</li>
  <li>And I search for XYZ product  </li>
  <li>And I add the product to the order</li>
  <li>And I select the order details page</li>
  <li>When I submit the order</li>
  <li>Then I see the order summary</li>
  </ul>
  
  <p>We can even put all those steps in the step code under 'Given I am on the order details page'</p>
  
  <p>However are we right to use Selenium to implement the Given? Or should we find some way to set all the relevant states/data in the session/database without going through the UI?</p>
  
  <p>I suspect that there is no right or wrong here. I have to say it is working very well for us but we are always looking to improve our approach. So would be very interested to hear from anyone with real experience.</p>
  
  <p>I hope Stack Overflow is the right forum for this (can't help but think it isn't - if so please don't shoot me down!)...</p>