Skip to content

Commit 51b21ef

Browse files
committed
Added Sample code
1 parent 4dd8301 commit 51b21ef

File tree

10 files changed

+153
-1
lines changed

10 files changed

+153
-1
lines changed

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
11
# maestro-sample
2-
Samples to support Mastro for iOS and Android apps on browserstack
2+
This repo contains a sample test suite that can be used to run maestro tests on App Automate.
3+
4+
### To Run tests:
5+
App for android: `sample_apps/sample_android.apk`
6+
App for iOS: `sample_apps/sample_ios.ipa`
7+
Upload the app using the command:
8+
```
9+
curl -u "<username>:<accesskey>" \
10+
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
11+
-F "file=@<path_to_app>"
12+
```
13+
This should generate and return an app hash.
14+
15+
__Test Suite__: `tests/`
16+
zip the `tests/` folder before uploading, and upload using the command:
17+
```
18+
curl -u "<username>:<accesskey>" \
19+
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/test-suite" \
20+
-F "file=@<path_to_zipped_testsuite>" \
21+
-F "custom_id=maestro_sample_tests"
22+
```
23+
This should generate and return a test suite hash.
24+
25+
Once the app and the zipped test suite are uploaded, use the following command to run tests:
26+
For Android:
27+
```
28+
curl -u "<username>:<accesskey>" \
29+
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
30+
-H "Content-Type: application/json" \
31+
-d '{
32+
"app": "bs://<app-hash>",
33+
"testSuite": "bs://<test-suite-hash>",
34+
"project": "Maestro_Sample_Repo",
35+
"execute": ["android-flow.yaml"],
36+
"devices": [
37+
"Google Pixel 9-16.0",
38+
"Samsung Galaxy S22-14.0",
39+
"Samsung Galaxy Tab S11-16.0"
40+
]
41+
}'
42+
```
43+
44+
For iOS:
45+
```
46+
curl -u "<username>:<accesskey>" \
47+
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/ios/build" \
48+
-H "Content-Type: application/json" \
49+
-d '{
50+
"app": "bs://<app-hash>",
51+
"testSuite": "bs://<test-suite-hash>",
52+
"project": "<Maestro Demo>",
53+
"execute": ["ios-flow.yaml"],
54+
"devices": [
55+
"iPhone 15-17.0",
56+
"iPhone 12 Pro Max-16.0",
57+
"iPad Pro 11 2021-18.0"
58+
]
59+
}'
60+
```
61+
This parallelly runs tests on the devices listed in the above command.

parent/android-flow.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
appId: org.wikipedia
2+
---
3+
- runFlow: subflows/launchapp-android.yaml
4+
- runFlow: subflows/signup-android.yaml
5+
- tapOn:
6+
id: "org.wikipedia:id/search_container"
7+
- tapOn:
8+
text: "Non existent view"
9+
optional: true
10+
- runScript: scripts/getSearchQuery.js
11+
- inputText: ${output.result}
12+
- assertVisible: ${output.result}

parent/ios-flow.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
appId: com.browserstack.Sample-iOS
2+
---
3+
- launchApp
4+
5+
- tapOn:
6+
text: "Web View"
7+
- tapOn:
8+
text: "Get started free"
9+
- assertVisible: "Create a FREE Account"
10+
- runFlow: subflows/signup-ios.yaml
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function username() {
2+
var date = new Date().getTime().toString();
3+
var username = `test_user_placeholder`.replace("placeholder", date);
4+
return username;
5+
}
6+
7+
function email() {
8+
var date = new Date().getTime().toString();
9+
var email = `[email protected]`.replace("placeholder", date);
10+
return email;
11+
}
12+
13+
function password() {
14+
var date = new Date().getTime().toString();
15+
var password = `test-user-password-placeholder`.replace("placeholder", date);
16+
return password;
17+
}
18+
19+
output.credentials = {
20+
email: email(),
21+
password: password(),
22+
username: username(),
23+
};

parent/scripts/getSearchQuery.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output.result = 'maestro';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
appId: org.wikipedia
2+
---
3+
- launchApp:
4+
clearState: true
5+
- tapOn:
6+
text: "Non existent view"
7+
optional: true
8+
- tapOn:
9+
id: "org.wikipedia:id/fragment_onboarding_forward_button"
10+
- tapOn:
11+
id: "org.wikipedia:id/fragment_onboarding_forward_button"
12+
- tapOn:
13+
id: "org.wikipedia:id/fragment_onboarding_forward_button"
14+
- tapOn:
15+
id: "org.wikipedia:id/fragment_onboarding_done_button"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
appId: org.wikipedia
2+
---
3+
- tapOn: "More"
4+
- tapOn: "LOG IN.*"
5+
- runScript: "../scripts/generateCredentials.js"
6+
- tapOn: "Username"
7+
- inputText: "${output.credentials.username}"
8+
- tapOn: "Password"
9+
- inputText: "${output.credentials.password}"
10+
- tapOn: "Repeat password"
11+
- inputText: "${output.credentials.password}"
12+
- tapOn: "Email.*"
13+
- inputText: "${output.credentials.email}"
14+
15+
# We won't actually create the account
16+
- back
17+
- back

parent/subflows/signup-ios.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
appId: com.browserstack.Sample-iOS
2+
---
3+
- runScript: "../scripts/generateCredentials.js"
4+
- tapOn: "Full name"
5+
- inputText: "${output.credentials.username}"
6+
- tapOn: "Business Email"
7+
- inputText: "${output.credentials.email}"
8+
- tapOn: "Password"
9+
- inputText: "${output.credentials.password}"
10+
11+
# We won't actually create the account
12+
# - tapOn: "Sign me up"
13+
14+
- back
15+
- back

sample_apps/sample_android.apk

14.9 MB
Binary file not shown.

sample_apps/sample_ios.ipa

5.04 MB
Binary file not shown.

0 commit comments

Comments
 (0)