Screenshot Configuration

Screenshot Configuration

ในการทำ screenshot application ที่เป็น iOS นั้น ทางทีม AtlasX ได้ใช้ฟีเจอร์ snapshot ของ fastlane ซึ่งจะต้องมีการตั้งค่าเพิ่มเติมดังนี้

  1. สร้าง UI Test target ไปในโปรเจ็กต์ Xcode (ดูวิธีสร้างที่นี่)
  2. เพิ่มไฟล์ SnapshotHelper.swift ไปที่ UI Test target ที่จะทำ screenshot
  3. เพิ่ม Scheme สำหรับ UI Test target ที่พึ่งสร้าง
  4. แก้ไข Scheme
  5. ในรายการทางด้านซ้าย คลิก “สร้าง” และเปิดใช้งาน “Run” สำหรับ UI Test target ที่พึ่งสร้าง
  6. คลิกเปิดใช้งาน Shared box สำหรับ scheme ที่พึ่งสร้าง
  7. เพิ่ม code ด้านล่างในหน้าที่ต้องการทำ screenshotsnapshot("01LoginScreen")
  8. เพิ่ม code ด้านล่างที่ method setUp()let app = XCUIApplication() setupSnapshot(app) app.launch()

Snapfile Configuration

ในการกำหนดการทำ screenshot นั้นสามารถตั้งค่าได้ที่ไฟล์ Snapfile ซึ่ง option หลัก ๆ ที่สามารถกำหนดได้ประกอบไปด้วย

  1. Devices ที่จะทำ snapshot
  2. ภาษา
  3. 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 ได้ ซึ่งสามารถทำได้ดังนี้

  1. แก้ไขไฟล์ Framefile.json
  2. แก้ไขไฟล์ keyword.strings และ title.strings ซึ่ง 2 ไฟล์นี้จะอยู่ใน
    folder ของแต่ละภาษา (อย่างละ 1 ไฟล์ต่อ 1 ภาษา)
fastlane
└── screenshots
   ├── en-US
   │   ├── keyword.strings
   │   └── title.strings
   └── th-TH
       ├── keyword.strings
       └── title.strings

Framefile.json Parameters

ParameterDescription
defaultเป็น object ที่กำหนดค่าพื้นฐานของรูป เช่น ตัวอักษร ขนาดรูป เป็นต้น
fontPath ของ font
font_sizeขนาด font ของ keyword และ title
colorสีของ keyword และ title
paddingระยะขอบระหว่างรูปที่ capture มากับ background
backgroundPath ของภาพพื้นหลังที่ใช้ประกอบกับรูปที่ 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 ที่จะแสดง