I personally like having the page object act as a the web page itself, providing me actions to perform and validation methods to use. For example, I keep all of my CSS, ID, etc. selectors within the page object itself. This way, if there is ever an update to the webpage which breaks the tests, I simply go to the corresponding Page Object for that web page and update the selector there.
As far as test data, I have some other files (classes, properties, etc.) that I use to pull test data from eg. test users. The test classes themselves pull this test data and pass it into the Page Objects (when needed), or the Page Object methods for validation purposes.
An example of a test data class (mine is a bit more complex, but this is a simple example):
public TestUser(){
username = getUniqueUser();
password = "";
name = "Test User";
email = getUniqueEmail(username);
}
tl;dr;
- I keep the html selectors IN their respective Page Objects (can use sub-page objects for re-use if needed).
- I keep the test data mixed between classes, property files, and test classes.