diff --git a/README.md b/README.md index e48abdd..b35e7ea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,62 @@ -# maestro-ios-sample-browserstack -Samples to support Mastro for iOS apps on browserstack +# maestro-sample +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 ":" \ +-X POST "https://api-cloud.browserstack.com/app-automate/upload" \ +-F "file=@" +``` +This should generate and return an app hash. + +__Test Suite__: `tests/` +zip the `tests/` folder before uploading, and upload using the command: +``` +curl -u ":" \ +-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/test-suite" \ +-F "file=@" \ +-F "custom_id=maestro_sample_tests" +``` +This should generate and return a test suite hash. +Note: Zip only the parent folder of your test suite. Ensure that no app files are included inside the zipped test suite. + +Once the app and the zipped test suite are uploaded, use the following command to run tests: +For Android: +``` +curl -u ":" \ + -X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \ + -H "Content-Type: application/json" \ + -d '{ + "app": "bs://", + "testSuite": "bs://", + "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 ":" \ + -X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/ios/build" \ + -H "Content-Type: application/json" \ + -d '{ + "app": "bs://", + "testSuite": "bs://", + "project": "", + "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. diff --git a/parent/android-flow.yaml b/parent/android-flow.yaml new file mode 100644 index 0000000..58cb88b --- /dev/null +++ b/parent/android-flow.yaml @@ -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} \ No newline at end of file diff --git a/parent/ios-flow.yaml b/parent/ios-flow.yaml new file mode 100644 index 0000000..c0aa2f2 --- /dev/null +++ b/parent/ios-flow.yaml @@ -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 \ No newline at end of file diff --git a/parent/scripts/generateCredentials.js b/parent/scripts/generateCredentials.js new file mode 100644 index 0000000..46f8cce --- /dev/null +++ b/parent/scripts/generateCredentials.js @@ -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 = `test-user-placeholder@test.com`.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(), +}; diff --git a/parent/scripts/getSearchQuery.js b/parent/scripts/getSearchQuery.js new file mode 100644 index 0000000..208ac16 --- /dev/null +++ b/parent/scripts/getSearchQuery.js @@ -0,0 +1 @@ +output.result = 'maestro'; diff --git a/parent/subflows/launchapp-android.yaml b/parent/subflows/launchapp-android.yaml new file mode 100644 index 0000000..e9ee46f --- /dev/null +++ b/parent/subflows/launchapp-android.yaml @@ -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" diff --git a/parent/subflows/signup-android.yaml b/parent/subflows/signup-android.yaml new file mode 100644 index 0000000..dc1e021 --- /dev/null +++ b/parent/subflows/signup-android.yaml @@ -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 diff --git a/parent/subflows/signup-ios.yaml b/parent/subflows/signup-ios.yaml new file mode 100644 index 0000000..623ee3e --- /dev/null +++ b/parent/subflows/signup-ios.yaml @@ -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 \ No newline at end of file diff --git a/sample_apps/sample_android.apk b/sample_apps/sample_android.apk new file mode 100644 index 0000000..6b206b3 Binary files /dev/null and b/sample_apps/sample_android.apk differ diff --git a/sample_apps/sample_ios.ipa b/sample_apps/sample_ios.ipa new file mode 100644 index 0000000..c1891b8 Binary files /dev/null and b/sample_apps/sample_ios.ipa differ