'Is it a wise thing to add validation functions into the Page Object Classes in a selenium automation framework based on Page Object Model?

I've frequently seen code where the test validation functions are frequently written into the Page Object classes themselves. Is there any use to doing this? Maybe I'm missing something but I feel that this only has drawbacks.

  1. If you're validating the same thing across different tests then it seems like you're duplicating tests. If you really must add validation functions - it must be very very selected few which you're sure is being used across multiple tests. More often than not, this isn't the case.
  2. Adding validation methods quickly bloats up the Page Object Classes and decreases visibility (makes everything look congested).
  3. It also reduces modularity. Validation is something test case related. So validation functions should ideally be written into the test classes.

Would it be a wise thing to avoid writing validation functions inside the Page Object classes?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source