When performing automated login for a Google account in test cases, Google may block the login depending on the account used.
MagicPod provides a mechanism that prevents blocking when running tests using Chrome or Edge. However, tests may occasionally fail due to identity verification screens like the one shown below appearing unexpectedly.
As a countermeasure, you can improve test stability by ensuring that two-factor authentication using Google Authenticator is always performed.
This article explains how to log in using two-factor authentication.
Table of Contents
Preparation
Turn on 2-step verification process for the target Google account and add the authentication system (Google Authenticator) on this page.
When adding the authentication system, click "Can't scan it?" and save the displayed authentication key. This key will be used to generate passcodes within the test case.
Refer to this guide for details: Test apps and websites that use two-factor authentication
Setup is complete once the two-step verification process is enabled and the authentication system has been added as shown below.
Login Method
The actual screen order and user interface may differ from what is shown here. Please use this help page as a reference and adjust the steps according to your actual screen.
-
Navigate to the Google authentication page and enter your email address and password.
-
After entering your password, click “Try another way” on the next screen. A list of alternative login methods will be displayed. Then, click “Get a verification code from the Google Authenticator app”.
-
Generate the passcode using the Store 2FA passcode command. Use the authentication key saved during the preparation step for this command. For security reasons, make sure to store the authentication key as a secret shared variable, like ${2factor_key} in the step image below.
-
Two-factor authentication may fail depending on the timing. It is recommended to use a Conditional command to retry authentication if it fails. In the example below, if the “Next” button is still displayed after 5 seconds, it is considered a failed login and the authentication process is retried.
Overview of the Entire Step Flow
Example of Shared Variable Settings
Additional Information
Limitations
-
Automatic login cannot be bypassed on Firefox, Safari, or Internet Explorer 11.
-
Please note that if Google changes its mechanisms for blocking automated logins or performing identity verification, the login method described here may no longer work.
Accounts less likely to be blocked
Newly created Google accounts appear less likely to be blocked during automated login. If the steps above cannot be used (e.g., when testing with Safari), consider creating a new Google account.