Monitoring a login scenario with browser checks
Scenarios where a user provides credentials to get access to a web app are extremely common. They are also a great candidate for a browser check as these site transactions tend to be very crucial.
Using Vercel deployment protection? Read this section on how to make this work with Checkly.
To get started, check out the video below 👇
Username / password login
The code snippet below shows how you can log into GitHub.
In certain cases, for example with Vercel password-protected deployments, websites might require a password to be entered before the target page is made available. Much like login cases, this can be solved directly using Playwright Test following the example above.
However, notice we are hard coding the username and password into our script. That’s never a good idea… Better to replace them with some environment variables. Read more about how to use environment variables in your browser checks.
Social Login
Authenticating via social login providers like Facebook, Google and GitHub can be a bit tricky to script because of the redirects involved. Also, many providers make their login pages “bot resistant” which makes scripting harder. The example below uses the Google social login option on the Checkly login page.
Note the following:
- We of course store our credentials in environment variables.
- Playwright Test’s locators will wait for your elements to be visible until the test times out (which will make the check fail).
More resources
- Playwright Authentication Guide
- Microsoft Live Login
- Login with Google
- How to Bypass TOTP-Based 2FA Login Flows
Last updated on December 13, 2024. You can contribute to this documentation by editing this page on Github