When performing automated login for a Google account in test cases, Google may block the login depending on the account used. If this occurs, you can avoid the block with the following measures:
- Select the "Browser" platform when creating the project.
- Use Chrome or Edge (Chromium) as the browser.
- Enable two-factor authentication (2FA) for more stable test cases.
Table of Contents
- Test case example
- Limitations
- Note 1. Why use two-factor authentication?
- Note 2. About device type
- Note 3. Accounts less likely to be blocked
Test case example
-
Navigate to the Google sign-in page(https://accounts.google.com?hl=en)
- You can specify the language in the URL (e.g., "hl=en") as needed
- Input the Google account email address and click "Next"
- Input password, and click "Next"
- If the Google Authenticator element is not initially displayed, scroll and click "try another way"
- Usually you will need to click "try another way" as shown on the screen below:
- If repeated login attempts are made and the screen below is displayed, you will need to move on to the next step.
- Click "Google Authenticator" as shown in the image above.
- Login using two-factor authentication.
- Refer to this guide for details: Test apps and websites that use two-factor authentication.
- If two-factor authentication fails, attempt the process again.
- Failure may occur depending on the timing of the 2FA passcode retrieval.
Limitations
If Google modifies its mechanism for prohibiting automatic login, the steps outlined here may no longer work.
Note 1. Why use two-factor authentication?
Without 2FA, fewer steps are required for login, but identity verification screens that appear unpredictably (such as the one below) may cause test failures. Enabling 2FA for every login iproves test stability.
Note 2. About device type
As described above, you can avoid Google login blocks by selecting "Browser" platform in creating project and by using Chrome or Edge (Chromium).
Any device type selection is acceptable
Project's Platform |
Device Type | OS | Browser |
Browser |
Desktop | arbitrary |
Edge(Chromium) Chrome |
Browser |
Mobile Emulation (Chrome) | Android | Chrome |
Browser | Mobile Real Device | Android | Chrome |
Note 3. 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.