Screenshot Configuration
ในการทำ screenshot application ที่เป็น iOS นั้น ทางทีม AtlasX ได้ใช้ฟีเจอร์ snapshot ของ fastlane ซึ่งจะต้องมีการตั้งค่าเพิ่มเติมดังนี้
- สร้าง UI Test target ไปในโปรเจ็กต์ Xcode (ดูวิธีสร้างที่นี่)
- เพิ่มไฟล์
SnapshotHelper.swiftไปที่ UI Test target ที่จะทำ screenshot - เพิ่ม Scheme สำหรับ UI Test target ที่พึ่งสร้าง
- แก้ไข Scheme
- ในรายการทางด้านซ้าย คลิก “สร้าง” และเปิดใช้งาน “Run” สำหรับ UI Test target ที่พึ่งสร้าง
- คลิกเปิดใช้งาน Shared box สำหรับ scheme ที่พึ่งสร้าง
- เพิ่ม code ด้านล่างในหน้าที่ต้องการทำ screenshot
snapshot("01LoginScreen") - เพิ่ม code ด้านล่างที่ method
setUp()let app = XCUIApplication() setupSnapshot(app) app.launch()
Snapfile Configuration
ในการกำหนดการทำ screenshot นั้นสามารถตั้งค่าได้ที่ไฟล์ Snapfile ซึ่ง option หลัก ๆ ที่สามารถกำหนดได้ประกอบไปด้วย
- Devices ที่จะทำ snapshot
- ภาษา
- Scheme สำหรับ UI Test target ที่มีการทำ snapshot นอกจากนี้สามารถลองศึกษาเพิ่มเติมได้ที่นี่
ตัวอย่างการกำหนดค่าใน Snapfile
# Uncomment the lines below you want to change by removing the # in the beginning
# A list of devices you want to take the screenshots from
devices([
"iPhone 8",
"iPhone 8 Plus",
# "iPhone SE",
# "iPhone X",
# "iPad Pro (12.9-inch)",
# "iPad Pro (9.7-inch)",
# "Apple TV 1080p",
# "Apple Watch Series 6 - 44mm"
])
# languages([
# "en-US",
# "de-DE",
# "it-IT",
# ["pt", "pt_BR"] # Portuguese with Brazilian locale
# ])
# The name of the scheme which contains the UI Tests
scheme("FastlaneTestUIWithScreenCaptureTests 1")
# Where should the resulting screenshots be stored?
# output_directory("./screenshots")
# remove the '#' to clear all previously generated screenshots before creating new ones
clear_previous_screenshots(true)
# Remove the '#' to set the status bar to 9:41 AM, and show full battery and reception. See also override_status_bar_arguments for custom options.
# override_status_bar(true)
# Arguments to pass to the app on launch. See https://docs.fastlane.tools/actions/snapshot/#launch-arguments
# launch_arguments(["-favColor red"])
# For more information about all available options run
# fastlane action snapshot
Frame Screenshot Configuration
เราสามารถกำหนด frame ของการทำ screenshot ได้ ซึ่งสามารถทำได้ดังนี้
- แก้ไขไฟล์ Framefile.json
- แก้ไขไฟล์ keyword.strings และ title.strings ซึ่ง 2 ไฟล์นี้จะอยู่ใน
folder ของแต่ละภาษา (อย่างละ 1 ไฟล์ต่อ 1 ภาษา)
fastlane
└── screenshots
├── en-US
│ ├── keyword.strings
│ └── title.strings
└── th-TH
├── keyword.strings
└── title.stringsFramefile.json Parameters
| Parameter | Description |
|---|---|
default | เป็น object ที่กำหนดค่าพื้นฐานของรูป เช่น ตัวอักษร ขนาดรูป เป็นต้น |
font | Path ของ font |
font_size | ขนาด font ของ keyword และ title |
color | สีของ keyword และ title |
padding | ระยะขอบระหว่างรูปที่ capture มากับ background |
background | Path ของภาพพื้นหลังที่ใช้ประกอบกับรูปที่ capture |
stack_title | ระบุการแสดงผลของ title และ keyword ว่าจะอยู่บรรทัดเดียวกัน หรีอคนละบรรทัด(true คือ คนละบรรทัด) |
title_below_image | ระบุการแสดงผลของ title และ keyword ว่าจะอยู่ด้านบน หรือด้านล่างของรูป |
data | จะเป็น object ที่เอาไว้ custom ค่าของแต่ละหน้า |
filter | ชื่อของหน้าที่จะ custom **ชื่อต้องมีระบุใน file keyword.strings และ title.strings เช่น custom สีของ keyword ดังใน file ตัวอย่าง |
Note
⚠️ ปัจจุบันยังมีบัค title และ keyword รับรองแค่ภาษาอังกฤษ For more imformation visit https://docs.fastlane.tools/actions/frame_screenshots/
keyword.strings and title.strings Parameters
“Screen_capture_name”, “Keyword or title strings” เปลี่ยน Screen_capture_name เป็นชื่อของหน้าที่จะใส่ keyword หรือ title
เปลี่ยน Keyword or title strings เป็น keyword หรือ title ที่จะแสดง