Log in to a Google account on an Android device for your Espresso tests
Log in to a Google account on an Android device for your Espresso tests on BrowserStack App Automate. Test in-app purchases and Play Store downloads.
This feature will be deprecated on 30 September 2024. Make sure you automate the Google login process and make other necessary code changes before this date. Technical limitations may prevent the feature from working after deprecation.
If you want to test end to end flows with your app, you can also log in to a Google account on BrowserStack devices. This can be useful to test scenarios such as the following:
- Test Google in-app purchase flows.
- Test accepting payments using Google Pay.
- Test your app’s integration with other Google apps (e.g. Google Calendar).
You can also log in to a Google account to test the production version of your apps by downloading it from the Google Play Store. To log in to a Google account on the device, set the appStoreConfiguration parameter with your Google account credentials in the REST API request to start Espresso tests.
REST API endpoint:
POST /app-automate/espresso/v2/build
| Parameter | Description | Values |
|---|---|---|
appStoreConfiguration |
Set credentials for Google account login | Format: {"username": "play-store-email", "password": "play-store-password"} |
Example cURL request:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d '{"appStoreConfiguration": {"username": "play-store-email", "password": "play-store-password"}, "devices": ["Samsung Galaxy S8-7.0"], "app": "bs://f7c874f21852ba57957a3fdc33f47514288c4ba4", "testSuite": "bs://e994db8333e32a5863938666c3c3491e778352ff"}' \
-H "Content-Type: application/json"
Parallel tests with the same credentials can trigger Google’s anti-bot security measures. This may lead to additional security checks causing tests to fail. If the Google login feature on App Automate fails intermittently, automate the login flow directly within the test case.
Fix Google login issues
During test initialization, BrowserStack attempts to log in on the tested device using the specified Google account credentials. In certain cases, Google may pose a 2FA (Two-factor authentication) challenge, which requires you to approve login using a trusted device, an OTP (one-time password), or some other means. This causes your test build to fail. To fix this, try the following:
- Use a newly created Google account to sign in. Ensure that this account was never previously used to login on any other device or browser.
- Turn off the account’s security settings named 2-Step Verification and Use your phone to sign in.
If you are still facing issues with Google account login, reach out to BrowserStack support.
Your Google account credentials are secure as we clean the devices at the end of your test session.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!