How modularized should page class methods be?
When following the POM design pattern, how modularized/specific should the page class methods be? i.e. if I have a test that involves entering a username and password, is it better practice to:
enterPassword()methods in the appropriate page class and call both from my test method
- Create an
enterUserData()method instead that sends data to both fields
- Create all three methods and call
emmalee last edited by
If the fields are re-used elsewhere in the application, you might do better with
enterPassword()so you can call them for updating user data, changing user password, or forgot password scenarios.
If they're used only for logging in, you might find it simpler to just have an
If you find that you're going to enter username and password in some places, and some variation on username or password, you might be better off using all three with
It completely depends on what will work best with your application and how the fields are handled. What works well when every place you enter a username has a text field with the same ID and every place you enter a password has a password field with the same ID is not going to work the same when the username field is named differently on every page it appears.
As quite a few testers have said many times, there are no "best practices". There are only good practices which are more, or less, applicable to a specific situation.