From 0ddb88b45ccbb5c1c5ea9f3bb9639316dd03dad4 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Thu, 28 Sep 2023 20:29:45 +0200 Subject: [PATCH] Add Maestro screenshot generation --- maestro/01.yaml | 54 ++++++++++++++++++++++++++++++++++++ maestro/js/01-getCardInfo.js | 34 +++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 maestro/01.yaml create mode 100644 maestro/js/01-getCardInfo.js diff --git a/maestro/01.yaml b/maestro/01.yaml new file mode 100644 index 0000000000..18eb9a8309 --- /dev/null +++ b/maestro/01.yaml @@ -0,0 +1,54 @@ +appId: me.hackerchick.catima.debug +name: Generate main screen overview with 8 cards +--- +- launchApp: + appId: "me.hackerchick.catima.debug" + clearState: true +- evalScript: ${output.counter = 0} +# We only care about cardCount at this moment, but this way we can keep the card list in one script +- runScript: + file: js/01-getCardInfo.js + env: + INDEX: ${output.counter} +- repeat: + while: + true: ${output.counter < output.cardCount} + commands: + - runScript: + file: js/01-getCardInfo.js + env: + INDEX: ${output.counter} + - tapOn: + id: "me.hackerchick.catima.debug:id/fabAdd" # Add + - tapOn: + id: "me.hackerchick.catima.debug:id/fabOtherOptions" # More options + - tapOn: + id: "android:id/text1" + index: 0 # Add a card with no barcode + - inputText: 123456 + - tapOn: + id: "android:id/button1" # OK + - tapOn: + id: "me.hackerchick.catima.debug:id/thumbnail" # Thumbnail + - tapOn: + id: "android:id/text1" + index: 0 # Select color + - tapOn: + id: "android:id/button3" # Custom + # BUG: Erase text twice to work around https://github.com/mobile-dev-inc/maestro/issues/495 + - repeat: + times: 2 + commands: + - tapOn: + id: "me.hackerchick.catima.debug:id/cpv_hex" + - eraseText + - inputText: ${output.cardColor} + - tapOn: + id: "android:id/button1" # Select + - tapOn: + id: "me.hackerchick.catima.debug:id/storeNameEdit" # Name + - inputText: ${output.cardName} + - tapOn: + id: "me.hackerchick.catima.debug:id/fabSave" # Save + - evalScript: ${output.counter = output.counter + 1} +- takeScreenshot: "screenshot-01" diff --git a/maestro/js/01-getCardInfo.js b/maestro/js/01-getCardInfo.js new file mode 100644 index 0000000000..e5c44925a8 --- /dev/null +++ b/maestro/js/01-getCardInfo.js @@ -0,0 +1,34 @@ +const cards = [{ + name: "Bookshop", + color: "673ab7" +}, { + name: "Cafeteria", + color: "795548" +}, { + name: "Clothing Store", + color: "ff4fa5" +}, { + name: "Department Store", + color: "000000" +}, { + name: "Grocery Store", + color: "4caf50" +}, { + name: "Pharmacy", + color: "00286e" +}, { + name: "Restaurant", + color: "59a2be" +}, { + name: "Shoe Store", + color: "9c27b0" +}] + +// For some reason Maestro passes this as a string with the value "0.0" +var index = Math.round(INDEX) + +console.log("Returning card " + (index + 1) + " of " + cards.length + " with name " + cards[index]['name'] + " and color " + cards[index]['color']) + +output.cardCount = cards.length +output.cardName = cards[index]['name'] +output.cardColor = cards[index]['color']