Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# maestro-sample
Samples to support Mastro for iOS and Android apps on browserstack
This repo contains a sample test suite that can be used to run maestro tests on App Automate.

### To Run tests:
App for android: `sample_apps/sample_android.apk`
App for iOS: `sample_apps/sample_ios.ipa`
Upload the app using the command:
```
curl -u "<username>:<accesskey>" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@<path_to_app>"
```
This should generate and return an app hash.

__Test Suite__: `tests/`
zip the `tests/` folder before uploading, and upload using the command:
```
curl -u "<username>:<accesskey>" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/test-suite" \
-F "file=@<path_to_zipped_testsuite>" \
-F "custom_id=maestro_sample_tests"
```
This should generate and return a test suite hash.

Once the app and the zipped test suite are uploaded, use the following command to run tests:
For Android:
```
curl -u "<username>:<accesskey>" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
-H "Content-Type: application/json" \
-d '{
"app": "bs://<app-hash>",
"testSuite": "bs://<test-suite-hash>",
"project": "Maestro_Sample_Repo",
"execute": ["android-flow.yaml"],
"devices": [
"Google Pixel 9-16.0",
"Samsung Galaxy S22-14.0",
"Samsung Galaxy Tab S11-16.0"
]
}'
```

For iOS:
```
curl -u "<username>:<accesskey>" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/ios/build" \
-H "Content-Type: application/json" \
-d '{
"app": "bs://<app-hash>",
"testSuite": "bs://<test-suite-hash>",
"project": "<Maestro Demo>",
"execute": ["ios-flow.yaml"],
"devices": [
"iPhone 15-17.0",
"iPhone 12 Pro Max-16.0",
"iPad Pro 11 2021-18.0"
]
}'
```
This parallelly runs tests on the devices listed in the above command.
12 changes: 12 additions & 0 deletions parent/android-flow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
appId: org.wikipedia
---
- runFlow: subflows/launchapp-android.yaml
- runFlow: subflows/signup-android.yaml
- tapOn:
id: "org.wikipedia:id/search_container"
- tapOn:
text: "Non existent view"
optional: true
- runScript: scripts/getSearchQuery.js
- inputText: ${output.result}
- assertVisible: ${output.result}
10 changes: 10 additions & 0 deletions parent/ios-flow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
appId: com.browserstack.Sample-iOS
---
- launchApp

- tapOn:
text: "Web View"
- tapOn:
text: "Get started free"
- assertVisible: "Create a FREE Account"
- runFlow: subflows/signup-ios.yaml
23 changes: 23 additions & 0 deletions parent/scripts/generateCredentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function username() {
var date = new Date().getTime().toString();
var username = `test_user_placeholder`.replace("placeholder", date);
return username;
}

function email() {
var date = new Date().getTime().toString();
var email = `[email protected]`.replace("placeholder", date);
return email;
}

function password() {
var date = new Date().getTime().toString();
var password = `test-user-password-placeholder`.replace("placeholder", date);
return password;
}

output.credentials = {
email: email(),
password: password(),
username: username(),
};
1 change: 1 addition & 0 deletions parent/scripts/getSearchQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.result = 'maestro';
15 changes: 15 additions & 0 deletions parent/subflows/launchapp-android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: org.wikipedia
---
- launchApp:
clearState: true
- tapOn:
text: "Non existent view"
optional: true
- tapOn:
id: "org.wikipedia:id/fragment_onboarding_forward_button"
- tapOn:
id: "org.wikipedia:id/fragment_onboarding_forward_button"
- tapOn:
id: "org.wikipedia:id/fragment_onboarding_forward_button"
- tapOn:
id: "org.wikipedia:id/fragment_onboarding_done_button"
17 changes: 17 additions & 0 deletions parent/subflows/signup-android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
appId: org.wikipedia
---
- tapOn: "More"
- tapOn: "LOG IN.*"
- runScript: "../scripts/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
- back
15 changes: 15 additions & 0 deletions parent/subflows/signup-ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: com.browserstack.Sample-iOS
---
- runScript: "../scripts/generateCredentials.js"
- tapOn: "Full name"
- inputText: "${output.credentials.username}"
- tapOn: "Business Email"
- inputText: "${output.credentials.email}"
- tapOn: "Password"
- inputText: "${output.credentials.password}"

# We won't actually create the account
# - tapOn: "Sign me up"

- back
- back
Binary file added sample_apps/sample_android.apk
Binary file not shown.
Binary file added sample_apps/sample_ios.ipa
Binary file not shown.
Loading