title: Cucumber Selenium - fill in web form
body: <p>What's the best way to fill in a web form with lots of text inputs if the project is using Cucumber and the Page Object Model?</p>
  
  <p>For example, let's say the feature file is something like this:</p>
  
  <pre><code>Scenario: As someone who wants to sign up
      When I visit the homepage
      And I click on the Register button
      And I enter my firstname
      And I enter my surname
      And I enter my email address
      And I enter a new password
      And I re-enter my new password
      And I agree to the terms and conditions
      And I click the Submit button
      Then I should see a welcome page
  </code></pre>
  
  <p>I understand that the step defs generated by Cucumber would generate a separate method for each of these, which is fine. Would I then have to implement each of these steps in the "RegistrationPage" in its own method? What I'm trying to get at is: is there a way to implement a kind of "fillInform()" method instead of separate methods in the RegistrationPage?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The question I asked is probably wrong (I was trying to keep it short). My objective is to be able to do something like this:</p>
  
  <pre><code>Scenario Outline: As someone who wants to sign up
      When I visit the homepage
      And I click on the Register button
  
      And I enter my "&lt;firstname&gt;" in the firstname input
      And I enter my "&lt;surname&gt;" in the surname input
      And I enter my "&lt;emailaddress&gt;" in the email input
      And I enter my "&lt;password&gt;" in the password input
      And I enter my "&lt;password&gt;" in the password confirmation input
      And I agree to the terms and conditions
      And I click the Submit button
      Then I expect the registration to "&lt;ExpectedResult&gt;"
  
      Examples:
      | firstname | surname    | emailaddress          | password       | ExpectedResult |
      | First     | User       | first@somewhere.com   |                | Fail           |
      | Second    | User       | second@somewhere.com  | .              | Fail           |
      | Third     | User       | third@somewhere.com   | toofew         | Fail           |
      | Fourth    | User       | fourth@somewhere.com  | weakpassword   | Fail           |
      | Fifth     | User       | fifth@somewhere.com   | MissingNumber  | Fail           |
      | Sixth     | User       | sixth@somewhere.com   | m1ssingc4pital | Fail           |
      | seventh   | User       | seventh@somewhere.com | CapsAndNumb3r  | Pass           |
  </code></pre>
  
  <p>Given such a scenario outline, would it still be possible to fill in the registration form using a single method? Something I have thought of (and I'm not sure what the implications of this would be) is to:</p>
  
  <pre><code>@When("^I enter \"([^\"]*)\" in the firstname input$")
  public void enterFirstname(String firstname) {
      registrationPage.firstname = firstname;
  }
  </code></pre>
  
  <p>and then, when the test presses the "Submit" button:</p>
  
  <pre><code>@When("^I click the Submit button$")
  public void clickSubmitButton() {
      registrationPage.fillInForm();
      registrationPage.clickJoinButton();
  }
  </code></pre>
  
  <p>However, doing it this way just doesn't <em>"feel right"</em> to me (although I could be mistaken - perhaps it's acceptable?)</p>