This document provides instructions on setting up automated screenshots for the Tip Calculator React Native app using Maestro and Fastlane for both iOS and Android platforms.
Automated screenshots are essential for app store submissions and marketing materials. This guide covers two popular tools:
pnpm install -g eas-cli)curl -Ls "https://get.maestro.mobile.dev" | bash
# macOS
brew install fastlane
# Or using Ruby
gem install fastlane
Since this is an Expo app, you’ll need to build native binaries for screenshot automation:
# Build for Android
eas build -p android --profile production
# Build for iOS
eas build -p ios --profile production
Download the built APKs/IPAs from the EAS dashboard.
For consistent screenshots, use the same device/emulator configuration:
Maestro is great for interactive screenshots that require UI interactions.
maestro directory in your project root:
mkdir maestro
maestro/calculator_flow.yamlappId: com.subnext.tipcalcbillsplit # Update with your actual app ID
---
- launchApp
- tapOn: "Bill Amount"
- inputText: "100.00"
- tapOn: "15%" # Select tip percentage
- tapOn: "No. of People"
- tapOn: "+" # Increase to 2 people
- takeScreenshot: calculator-filled
- tapOn: "20%" # Change tip to 20%
- takeScreenshot: calculator-20-percent
# For Android
maestro test maestro/ --platform android
# For iOS
maestro test maestro/ --platform ios
Screenshots will be saved in the maestro/screenshots directory.
Current Maestro Flow Coverage:
Fastlane provides plugins specifically for screenshot generation.
fastlane init
fastlane add_plugin screengrab # For Android
fastlane add_plugin snapshot # For iOS
Create fastlane/Fastfile with Android screenshot configuration:
platform :android do
desc "Take screenshots"
lane :screenshots do
screengrab(
app_apk_path: "path/to/your/app.apk",
tests_apk_path: "path/to/your/test.apk",
locales: ["en-US"],
clear_previous_screenshots: true,
app_package_name: "com.subnext.tipcalcbillsplit",
test_instrumentation_runner: "androidx.test.runner.AndroidJUnitRunner"
)
end
end
Add iOS configuration to fastlane/Fastfile:
platform :ios do
desc "Take screenshots"
lane :screenshots do
snapshot(
scheme: "YourAppScheme",
devices: ["iPhone 14"],
languages: ["en-US"],
clear_previous_screenshots: true
)
end
end
For Fastlane screenshots, you need UI tests that navigate the app and capture screenshots.
Create androidTest directory and add test:
// ScreenshotTest.kt
@RunWith(AndroidJUnit4::class)
class ScreenshotTest {
@get:Rule
val activityRule = ActivityTestRule(MainActivity::class.java)
@Test
fun testTakeScreenshot() {
// Navigate to calculator screen
onView(withId(R.id.bill_input)).perform(typeText("50.00"))
onView(withText("15%")).perform(click())
// Take screenshot
Screengrab.screenshot("calculator_filled")
}
}
Create UI test in Xcode:
// ScreenshotTest.swift
class ScreenshotTest: XCTestCase {
func testTakeScreenshot() {
let app = XCUIApplication()
app.launch()
// Navigate and fill calculator
let billField = app.textFields["Bill Amount"]
billField.tap()
billField.typeText("75.00")
let tipButton = app.buttons["20%"]
tipButton.tap()
// Take screenshot
snapshot("CalculatorFilled")
}
}
# Android
fastlane android screenshots
# iOS
fastlane ios screenshots
calculator-empty, calculator-filled, split-bill# Record interactions
maestro record
# View hierarchy
maestro hierarchy
# Verbose output
fastlane android screenshots --verbose
# Clean and retry
fastlane android screenshots --clean