title: Page Object Model Best Practices in Selenium
body: <p>When you are modelling your page objects, how would you deal with a page which has form and about 50 input fields on it? What is the best practice here?</p>
  
  <p>Would you create a page object and write a separate function for each input action? or would you write one function which parameters are passed to it and enters the text?</p>
  
  <p>e.g.</p>
  
  <pre><code>public void enterFirstName(String firstName) {
      driver.type("firstNameField", firstName);
  }
  
  public void enterSecondName(String secondName) {
      driver.type("secondNameField", secondName);
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>public void fillInForm(String inputFieldName, String text) {
      driver.type(inputFieldName, text);
  }
  </code></pre>
  
  <p>I can see in the first model, when writing tests, the tests are more descriptive, but if the page contains too many input fields, creating the page object becomes cumbersome.</p>
  
  <p>This post is also quite interesting in structuring selenium tests in Page Objects
  <a href="http://www.testingexcellence.com/functional-automated-testing-best-practices-with-selenium-webdriver/">Functional Automated Testing Best Practices with Selenium WebDriver</a></p>