We build model for each page with selenium page objects pattern. But for implementing one business feature, it will involve couple of pages. For example, creating one user, it involves AgreementPage and CreateUserPage like below
agreementPage = AgreementPage()
creatUserPage = agreementPae.accept()
createUserPage.typeEmail("your email address")
createUserPage.submit()
In our tests, many test cases require to create one user for preconditions. To reuse these code, we made one new Service tier. We move code into UserService.CreateUser(). Then our test scripts become
def test_create_user():
userService.CreateUser("email address")
#do assertion
def test_edit_user():
authenticationService.login("user name", "password")
userService.CreateUser("email addrss")
#do editing created user
def test_delete_user():
authenticationService.login("user name", "password")
userService.CreateUser("email addrss")
#do deleting created user
Because most features involve two pages or more, so page objects go into service tier. And in test scripts tier, it seems that we are testing services.But we do think service name is not friendly and not like talking with domain language.
I assume this is very common approach to do automation test, right? How do you naming service tier or how do you deal with resuing page objects?