Not Using Page-Objects

Definition:

  • Page objects are just a design pattern to ensure automated UI tests use reusable, modular code. Not using them, eg, writing WebDriver code directly in step definitions, means any changes to your UI will require updates in lots of different places instead of the one ‘page’ class.

Code Example:

[When(@'I buy some '(.*)' tea')]
public void WhenIBuySomeTea(string typeOfTea)
{
  Driver.FindElement(By.Id('tea-'+typeOfTea)).Click();
  Driver.FindElement(By.Id('buy')).Click();
}

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring