Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions maestro/google-login.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# We could save a few steps in this flow by immediately opening the Add Account screen in the Settings app:
# adb shell am start -a android.settings.ADD_ACCOUNT_SETTINGS -n com.android.settings/.accounts.AddAccountSettings;

# This flow requires passing the user name and password as parameters like so:
# maestro test -e [email protected] -e PASSWORD=123 google-login.yml

appId: "com.android.settings"
---
- launchApp
- scrollUntilVisible:
element: "Passwords, passkeys & accounts"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string seems to only be available in newer android versions (in API 33, it says Passwords and accounts), but as you said in the comments, we might be able to bypass those steps with the adb command above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point! I thought about being smart with regex, but it seemed simpler and less confusing to make 2 separate flows:

  • maestro/google-login/api/36.yml for API >= 36
  • maestro/google-login/api/32.yml for API >= 32

I'm not entirely sure if these are the exact API boundaries, but we can tweak as needed.

There's also a maestro/google-login/google-login.yml file, which selects the right API flow to use based on the API_VERSION parameter that is passed. I'm not sure of a way to automatically get the Android version in Maestro, but we can improve it if we find one. So to be clear, this is how it would work now:

maestro test \
  -e API_VERSION=36 \
  -e [email protected] \
  -e PASSWORD=123 \
  google-login.yml;

- tapOn: "Passwords, passkeys & accounts"
- runFlow:
when:
notVisible: "None selected"
commands:
- tapOn: "Change"
- tapOn: "None"
- tapOn: "Turn off"
- back
- tapOn: "Add account"
- tapOn: "Google"
- tapOn:
id: identifierId
- inputText: ${USERNAME}
- tapOn: NEXT
- assertVisible: "Show password"
- inputText: ${PASSWORD}
- tapOn: NEXT
- tapOn: "I agree"
- waitForAnimationToEnd
# Skip and cancel whatever Google asks us
- repeat:
while:
visible: "Cancel"
commands:
- tapOn: "Cancel"
- repeat:
while:
visible: "Skip"
commands:
- tapOn: "Skip"