Signups are key transactions in most web platforms, and therefore prime targets for automation.
Oftentimes, registering an account is where we will find longer forms asking the user to answer a variety of questions. Luckily, Puppeteer and Playwright are quick enough to blaze through these in seconds.
The flow will often match the following:
- Navigate to the signup form.
- Fill in all text fields, check all boxes etc.
- Submit the form by clicking a button.
We will likely want to also check that some change occurred in the UI to confirm that the registration worked.
Run this example as follows:
The normal signup flow might include asking the user to confirm their email address right away by navigating to a URL included in an automated email. Reliably replicating the steps needed to achieve that is not trivial. A possible solution to the issue is having the system under test distinguish between test sessions and normal user sessions, and skip the verification step for test sessions. A way to achieve this would be to check for a specific user agent ID which could be set as part of our test:
await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 \ (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 TEST_ID/<MY_SECRET>');
- Use environment variables to inject secrets.
- You might need to go through additional steps in case email confirmation or similar is required.