screenshots 패키지는 에뮬레이터, 시뮬레이터 및 실제 기기를 사용하여 iOS 및 안드로이드용 앱 스토어 준비 완료 스크린샷을 자동으로 생성합니다. 여러 지역 언어를 지원하며 플랫폼별 요구 사항에 맞는 프레임 옵션도 포함되어 있습니다. fastlane과 원활하게 통합되도록 설계되어 수작업 없이 고품질의 로컬라이즈된 스크린샷을 캡처함으로써 릴리스 프로세스를 간소화합니다. 다양한 지역에서 일관되고 전문적인 앱 스토어 비주얼을 유지하려는 팀에게 이상적입니다.
사용 사례
앱 스토어 스크린샷 생성 자동화
글로벌 릴리스를 위한 로컬라이즈된 스크린샷 생성
CI/CD 파이프라인과의 통합
Apple App Store 및 Google Play용 준수 스크린샷 준비
수동 테스트 및 캡처 작업 감소
주요 기능
iOS 시뮬레이터 및 안드로이드 에뮬레이터를 지원합니다
다중 로케일 스크린샷 생성
장치 모크업을 위한 내장 프레임
Fastlane 통합
실기기 지원
적합한 대상
모바일 개발 팀
CI/CD 자동화 워크플로
다양한 지역을 대상으로 하는 앱 출판사
fastlane 사용 개발자
일관된 앱 스토어 시각 효과가 필요한 팀
고려 사항
에뮬레이터 또는 실제 장치 설정이 필요합니다
특정 장치 프레임에 대해 추가 구성이 필요할 수 있습니다
완전한 자동화를 위해 fastlane에 의존
호환되는 빌드 구성이 있는 Flutter 앱에 한정
플랫폼별 종속성은 빌드 시간을 늘릴 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
A screenshot image with overlaid status bar placed in a device frame.
For an example of images generated with Screenshots on a live app in both stores see:
See a demo of Screenshots in action:
For introduction to Screenshots see https://medium.com/@nocnoc/automated-screenshots-for-flutter-f78be70cd5fd.
Screenshots
Screenshots is a standalone command line utility and package for capturing screenshot images for Flutter.
Screenshots will start the required android emulators and iOS simulators (or find attached devices), run tests, process the captured screenshots, and drop them off to Fastlane for delivery to both stores.
Screenshots is inspired by three tools from Fastlane:
Snapshots
This is used to capture screenshots on iOS using iOS UI Tests.
Screengrab
This captures screenshots on android using Android Espresso tests.
FrameIt
This is used to place captured iOS screenshots in a device frame.
Since all three of these Fastlane tools do not work with Flutter, Screenshots combines key features of these Fastlane tools into one tool.
Features
Since Flutter integration testing is designed to work transparently across iOS and Android, capturing images using Screenshots is easy.
Features include:
Works with existing tests
Add a single line for each screenshot.
Run tests on any device
Select the devices to run on using a convenient config file. Screenshots will find the devices (real or emulated) and run tests.
One run for both platforms Screenshots runs tests on both iOS and Android in one run.
(as opposed to making separate Snapshots and Screengrab runs)
One run for multiple locales
If app supports multiple locales, Screenshots will optionally set the locales listed in the config file before running each test.
One run for frames
Optionally places images in device frames in same run.
(as opposed to making separate FrameIt runs... which supports iOS only)
One run for clean status bars
Every image that Screenshots generates has a clean status bar.
(no need to run a separate stage to clean-up status bars)
Works with Fastlane Screenshots drops-off images where Fastlane expects to find them. Fastlane's deliver and supply can then be used to upload to respective stores.
Works with FrameIt
Works with Fastlane's FrameIt text and background feature to add text, etc... to a framed screenshot generated by screenshots.
Works with any attached real devices
Use any number of real devices to capture screenshots.
Additional automation features:
Screenshots runs in the cloud.
For live demo of Screenshots running with the internationalized example app on macOS, linux and windows in cloud, see below
Screenshots works with any CI/CD tool.
For live demo of uploading images, generated by Screenshots, to both store consoles, see demo of Fledge at https://github.com/mmcc007/fledge#demo
Installation
On macOS:
brew update && brew install imagemagick
pub global activate screenshots
On linux:
# Debian, Ubuntu or Linux Mintsudo apt-get install imagemagick
# Fedora, CentOS or RHELsudo yum install ImageMagick
# OpenSUSEsudo zypper install imagemagick
pub global activate screenshots
Note: on linux ImageMagick is often already installed.
On windows:
choco install imagemagick.app
pub global activate screenshots
Note: ImageMagick v7 or later is recommended on windows.
If pub is not found, add to PATH using:
On macOS/Linux:
export PATH="<path to flutter installation directory>/bin/cache/dart-sdk/bin:$PATH"
On windows:
set PATH=<path to flutter installation directory>\flutter\bin\cache\dart-sdk\bin;%APPDATA%\Pub\Cache\bin;%PATH%
Note: if running on Windows or Linux, can only run android devices/emulators. To also run on macOS use a CI that supports macOS.
Usage
screenshots
Or, if using a config file other than the default 'screenshots.yaml':
screenshots -c <path to config file>
Other options:
usage: screenshots [-h] [-c <config file>] [-m <normal|recording|comparison|archive>] [-f <flavor>] [-b <true|false>] [-v]
sample usage: screenshots
-c, --config=<screenshots.yaml> Path to config file.
(defaults to "screenshots.yaml")
-m, --mode=<normal|recording|comparison|archive> If mode is recording, screenshots will be saved for later comparison.
If mode is comparison, screenshots will be compared with recorded.
If mode is archive, screenshots will be archived (and cannot be uploaded via fastlane).
[normal (default), recording, comparison, archive]
-f, --flavor=<flavor name> Flavor name.
-b, --build=<true|false> Force build and install of app for all devices.
Override settings in screenshots.yaml (if any).
[true, false]
-v, --verbose Noisy logging, including all shell commands executed.
-h, --help Displaythis help information.
Modifying tests for Screenshots
A special function is provided in the Screenshots package that is called by the test to capture a screenshot.
Screenshots will then process the images appropriately during a Screenshots run.
To capture screenshots in tests:
Add Screenshots package in app's pubspec.yaml's dev_dependencies section
dev_dependencies:screenshots:^<currentversion>
In tests
Import the dependency
import'package:screenshots/screenshots.dart';
Create the config at start of test
final config = Config();
Throughout the test make calls to capture screenshots
awaitscreenshot(driver, config, 'myscreenshot1');
Note: make sure screenshot names are unique across all tests.
Note: to turn off the debug banner, in the integration test's main(), call:
WidgetsApp.debugAllowBannerOverride = false; // remove debug banner for screenshots
Configuration
Screenshots uses a configuration file to configure a run.
The default config filename is screenshots.yaml:
# A list of screen capture teststests:# Note: flutter driver expects a pair of files eg, main1.dart and main1_test.dart-test_driver/main1.dart-test_driver/main2.dart# Interim location of screenshots from testsstaging:/tmp/screenshots# A list of locales supported by the applocales:-en-US-de-DE# A map of devices to emulatedevices:ios:iPhone XS Max:iPhone 11 Pro:frame:false# no screen avail so frame must be falseiPad Pro (12.9-inch) (3rd generation):orientation:-Portrait# default -LandscapeRightandroid:Nexus 6P:SM G965F:# a real attached device (frame and orientation disabled)# Frame screenshotsframe:true
Device Parameters
Individual devices can be configured in screenshots.yaml by specifying per device parameters.
Parameter
Values
Required
Description
frame
true/false
optional
Controls whether screenshots generated on the device should be placed in a frame. Overrides the global frame setting (see example screenshots.yaml above).
Screenshots can be used to monitor any unexpected changes to the UI by comparing the new screenshots to previously recorded screenshots. Any differences will be highlighted in a 'diff' image for review.
To use this feature:
Add a recording directory to screenshots.yaml
recording:/tmp/screenshots_record
Run a recording to capture expected screenshots:
screenshots -m recording
Run subsequent Screenshots with:
screenshots -m comparison
Screenshots will compare the new screenshots with the recorded screenshots and generate a 'diff' image for each screenshot that does not compare. The diff image highlights the differences in red.
Archive Mode
To generate screenshots for local use, such as generating reports of changes to UI over time, etc... use 'archive' mode.
To enable this mode:
Add an archive directory to screenshots.yaml:
archive:/tmp/screenshots_archive
Run Screenshots with:
$ screenshots -m archive
Integration with Fastlane
Since Screenshots is intended to be used with Fastlane, after Screenshots completes, the images can be found in the project at:
Images are in a format suitable for upload via deliver
and supply.
Tip: One way to use Screenshots with Fastlane is to call Screenshots before calling Fastlane (or optionally call from Fastlane). Fastlane (for either iOS or Android) will then find the images in the appropriate place.
(For a live demo of using Fastlane to upload screenshot images to both store consoles, see demo of Fledge at https://github.com/mmcc007/fledge#demo)
Fastlane FrameIt
iOS images generated by Screenshots can also be further processed using FrameIt's text and background feature.
In some cases it is useful to know what device, device type, screen size, screen orientation and locale the test is currently running with. To obtain this information use:
final screenshotsEnv = config.screenshotsEnv;
See https://github.com/flutter/flutter/issues/31609 for related flutter driver issue.
Upgrading
To upgrade, simply re-issue the install command
$ pub global activate screenshots
Note: the Screenshots version should be the same for both the command line and in the pubspec.yaml.
If upgrading the command line version of Screenshots, also upgrade
the version of Screenshots in the pubspec.yaml.
If upgrading the version of Screenshots in pubspec.yaml, also upgrade the command line version.
To check the version of Screenshots currently installed:
pub global list
Sample run on Travis and Appveyor
To view Screenshots running with the internationalized example app on macOS and linux in the cloud see:
https://travis-ci.com/mmcc007/screenshots
To view the images generated by Screenshots during a run on travis see:
https://github.com/mmcc007/screenshots/releases/
To view a similar run on windows see:
https://ci.appveyor.com/project/mmcc007/screenshots
Running Screenshots in the cloud is useful for automating the generation of screenshots in a CI/CD environment.
Running Screenshots on macOS in the cloud can be used to generate screenshots when developing on Linux and/or Windows.
Related projects
To run integration tests on real devices in cloud:
https://github.com/mmcc007/sylph
To automate releases to both stores:
https://github.com/mmcc007/fledge