Advanced: Wikipedia Android
A complete example using Maestro + Wikipedia App
Content
Go through onboarding
Navigate dashboard
Scroll feed & search for item
Copy text & paste
Validate visible items
Authentication
Signup
Login
Use javascript
Onboarding
Launches app in clear state
Runs onboarding flow
Add language
Remove language
Complete onboarding
# run-test.yml
appId: org.wikipedia
---
- launchApp:
clearState: true
- runFlow: "onboarding/main.yml"# onboarding/onboarding.yml
appId: org.wikipedia
---
- runFlow: "add-language.yml"
- runFlow: "remove-language.yml"
- tapOn: "Continue"
- assertVisible: "New ways to explore"
- tapOn: "Continue"
- assertVisible: "Reading lists with sync"
- tapOn: "Continue"
- assertVisible: "Send anonymous data"
- tapOn: "Get started"# onboarding/add-language.yml
appId: org.wikipedia
---
- tapOn: "ADD OR EDIT.*"
- tapOn: "ADD LANGUAGE"
- tapOn:
id: ".*menu_search_language"
- inputText: "Greek"
- assertVisible: "Ελληνικά"
- tapOn: "Ελληνικά"
- tapOn: "Back"# onboarding/remove-language.yml
appId: org.wikipedia
---
- tapOn: "ADD OR EDIT.*"
- tapOn: "More options"
- tapOn: "Remove language"
- tapOn:
id: ".*wiki_language_checkbox"
index: 1
- tapOn:
id: ".*menu_delete_selected"
- tapOn: "OK"
- assertNotVisible: "Ελληνικά"
- tapOn: "Back"maestro test run-test.ymlNavigate main dashboard
Search & Save
Searches for a wiki page
Saves the wiki page in favorites
Returns to main dashboard
Feed
Scroll feed until it finds a particular article
Opens article
Copy & Paste
Scrolls feed until it finds a particular article
Copies article title
Pastes copied text into another field
Saved
Vaidates a particular page has been saved in our favorites
# run-test.yml
appId: org.wikipedia
---
- launchApp
- runFlow: "dashboard/search.yml"
- runFlow: "dashboard/feed.yml"
- runFlow: "dashboard/copy-paste.yml"
- runFlow: "dashboard/saved.yml"appId: org.wikipedia
---
- tapOn: "Search Wikipedia"
- inputText: "Sun"
- assertVisible: "Star in the Solar System"
- tapOn:
id: ".*page_list_item_title"
- tapOn:
id: ".*page_save"
- back
- backappId: org.wikipedia
---
- tapOn: "Explore"
- scrollUntilVisible:
element: "Today on Wikipedia.*"
- tapOn: "Today on Wikipedia.*"
- backappId: org.wikipedia
---
- tapOn: "Explore"
- scrollUntilVisible:
element: "Top read"
- copyTextFrom:
id: ".*view_list_card_item_title"
index: 0
- tapOn: "Explore"
- tapOn: "Search Wikipedia"
- inputText: "${maestro.copiedText}"
- back
- backappId: org.wikipedia
---
- tapOn: "Saved"
- tapOn: "Default list for your saved articles"
- assertVisible: "Sun"
- assertVisible: "Star in the Solar System"
- backmaestro test run-test.ymlAuthentication
Signup
Navigates to signup
Generates credentials using javascript
Fills input fields with generated credentials
Login
Navigates to login
Fetches a test user from a test api using javascript
Fill input fields with fetched credentials
# run-test.yml
appId: org.wikipedia
---
- launchApp
- runFlow: "auth/signup.yml"
- runFlow: "auth/login.yml"appId: org.wikipedia
---
- tapOn: "More"
- tapOn: "LOG IN.*"
- tapOn:
id: ".*create_account_login_button"
- runScript: "fetchTestUser.js"
- tapOn: "Username"
- inputText: "${output.test_user.username}"
- tapOn: "Password"
- inputText: "test-password"
- tapOn: "LOG IN"
# we won't actually login
- back
- backappId: org.wikipedia
---
- tapOn: "More"
- tapOn: "LOG IN.*"
- runScript: "generateCredentials.js"
- tapOn: "Username"
- inputText: "${output.credentials.username}"
- tapOn: "Password"
- inputText: "${output.credentials.password}"
- tapOn: "Repeat password"
- inputText: "${output.credentials.password}"
- tapOn: "Email.*"
- inputText: "${output.credentials.email}"
# We won't actually create the account
- back
- backJavascript scripts
function username() {
const date = new Date().getTime().toString();
return `test_user_${date}`;
}
function email() {
const date = new Date().getTime().toString();
return `test-user-${date}@test.com`;
}
function password() {
const date = new Date().getTime().toString();
return `test-user-password-${date}`;
}
output.credentials = {
email: email(),
password: password(),
username: username(),
};
// Fetches test user from API
function getTestUserFromApi() {
const url = `https://jsonplaceholder.typicode.com/users/1`;
const response = http.get(url);
const data = json(response.body);
return {
username: data.username,
email: data.email,
};
}
output.test_user = getTestUserFromApi();maestro test run-test.ymlLast updated
Was this helpful?
