When automating key site transactions, we inevitably stumble into login scenarios. In most cases, users need to be able to access accounts on a platform to get any value out of it. If they suddenly become unable to do so, we need to be informed as quickly as possible.
In its simplest form, a login procedure requires the user to:
- Navigate to the login form
- Fill in a username/email field
- Fill in a password field
- Click a button to finalise the login
At the end of our test, we need to check if our login procedure has been successful. For example, we could verify that an element is shown that we know only appears for logged-in users.
On our test site this could look like the following:
Run this example as follows. Replace the username and password placeholder with your own credentials.
- Use environment variables to inject secrets.
- You might need to wait for the navigation as you are redirected to the login screen/modal.