Search code examples
authenticationautomated-testswatinmembershipstatus

What is the ideal way to verify login with WatiN?


I am trying to find the best way to verify if the user is logged in and what role they are on, I'm thinking of a few ways to handle this.

1: Store the login status and role in a invisible control and read it.
2: Use a web service that WatiN can direct to that will return method calls

Any other ideas?


Solution

  • Does logging in produce visible changes in your UI? If it does, I would test for the existence of the markup which underlies these changes. If it doesn't I would ask myself the question, "What changes does logging in produce from a user's perspective?" I would then test for the existence of one or more of those changes. This might be something like the correct loading of a page that only a logged in user can access or the existence of a button or link to access content only provided to authenticated users.

    This is what WatiN is designed to test: correctness of application function from the perspective of an actual user. I would hate to see you have to resort to adding hidden fields or extra web services just to support your testing tools.