質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

1352閲覧

fastlane snapshotでスクリーンショットを撮りたい

pftyuk

総合スコア52

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2019/06/16 14:26

前提・実現したいこと

こちらを参考に、fastlaneを導入しsnapshotでスクリーンショットを取ろうとしてます。

テストコードまで書き終えて、ターミナルから以下コマンドを実行したのですが
snapshot resultsが❌になってしまい、スクリーンショットが取れていません。
生成される結果のhtmlは表示が空で、生成されるsnapshotフォルダ配下にも何も格納されてない状態です。

ログを見ても、解決方法がわからず手詰まりになってしまったため、ご教示頂きたいです。

bundle exec fastlane screenshots

実行結果とログ

$ bundle exec fastlane screenshots [✔] ???? [23:01:51]: ------------------------------ [23:01:51]: --- Step: default_platform --- [23:01:51]: ------------------------------ [23:01:51]: Driving the lane 'ios screenshots' ???? [23:01:51]: --------------------------------- [23:01:51]: --- Step: capture_screenshots --- [23:01:51]: --------------------------------- [23:01:52]: Successfully loaded '/Users/*****/Documents/fastlane-snapshot/fastlane/Snapfile' ???? +----------------------------+---------------+ | Detected Values from './fastlane/Snapfile' | +----------------------------+---------------+ | devices | ["iPhone 8"] | | languages | ["ja-JP"] | | output_directory | ./screenshots | | clear_previous_screenshots | true | +----------------------------+---------------+ [23:01:52]: $ xcodebuild -showBuildSettings -scheme fastlane-snapshot -project ./fastlane-snapshot.xcodeproj 2019-06-16 23:01:54.115 xcodebuild[69096:7098334] DTDeviceKit: deviceType from f218084929032a1cf72d6d10adad0d1cc89cc2a3 was NULL 2019-06-16 23:01:54.298 xcodebuild[69096:7098333] DTDeviceKit: deviceType from f218084929032a1cf72d6d10adad0d1cc89cc2a3 was NULL +----------------------------+--------------------------------------------------------+ | Summary for snapshot 2.125.2 | +----------------------------+--------------------------------------------------------+ | scheme | fastlane-snapshot | | project | ./fastlane-snapshot.xcodeproj | | output_directory | /Users/*****/Documents/fastlane-snapshot/screenshots | | devices | ["iPhone 8"] | | languages | ["ja-JP"] | | launch_arguments | [""] | | output_simulator_logs | false | | skip_open_summary | false | | skip_helper_version_check | false | | clear_previous_screenshots | true | | reinstall_app | false | | erase_simulator | false | | localize_simulator | false | | app_identifier | com.*****.fastlane-snapshot | | buildlog_path | ~/Library/Logs/snapshot | | clean | false | | number_of_retries | 1 | | stop_after_first_error | false | | result_bundle | false | | concurrent_simulators | true | | xcode_path | /Applications/Xcode.app | +----------------------------+--------------------------------------------------------+ [23:01:55]: Clearing previously generated screenshots [23:01:55]: Building and running project - this might take some time... [23:01:56]: Patching simulators '/Users/*****/Library/Preferences/com.apple.iphonesimulator.plist' to scale to 100% [23:01:58]: Running snapshot on: iPhone 8 [23:01:58]: $ set -o pipefail && xcodebuild -scheme fastlane-snapshot -project ./fastlane-snapshot.xcodeproj -derivedDataPath '/var/folders/9j/88s9hfds5y14rp9kznk0d5ph0000gn/T/snapshot_derived20190616-69084-qe6ksd' -destination 'platform=iOS Simulator,name=iPhone 8,OS=12.1' FASTLANE_SNAPSHOT=YES build test | tee /Users/*****/Library/Logs/snapshot/fastlane-snapshot-fastlane-snapshot.log | xcpretty [23:01:58]: ▸ Loading... [23:02:00]: ▸ 2019-06-16 23:02:00.236 xcodebuild[69191:7098856] DTDeviceKit: deviceType from f218084929032a1cf72d6d10adad0d1cc89cc2a3 was NULL [23:02:00]: ▸ Compiling ViewController.swift [23:02:05]: ▸ Compiling AppDelegate.swift [23:02:05]: ▸ Linking fastlane-snapshot [23:02:07]: ▸ Compiling Main.storyboard [23:02:08]: ▸ Compiling LaunchScreen.storyboard [23:02:08]: ▸ Processing Info.plist [23:02:09]: Running Tests: ▸ Touching fastlane-snapshot.app (in target: fastlane-snapshot) [23:02:09]: ▸ Build Succeeded [23:02:09]: ▸ Linking fastlane-snapshot [23:02:09]: ▸ Compiling fastlane_snapshotUITests.swift [23:02:10]: ▸ Compiling SnapshotHelper.swift [23:02:10]: ▸ Processing Info.plist [23:02:10]: ▸ Linking fastlane-snapshotUITests [23:02:11]: ▸ Copying /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework [23:02:11]: ▸ Copying /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest.framework [23:02:12]: Running Tests: ▸ Touching fastlane-snapshotUITests.xctest (in target: fastlane-snapshotUITests) [23:02:12]: ▸ 2019-06-16 23:02:12.137 xcodebuild[69191:7099803] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: [23:02:12]: ▸ /var/folders/9j/88s9hfds5y14rp9kznk0d5ph0000gn/T/snapshot_derived20190616-69084-qe6ksd/Logs/Test/Run-fastlane-snapshot-2019.06.16_23-02-00-+0900.xcresult/2_Test/Diagnostics/fastlane-snapshotUITests-B3404761-EA87-4E77-A12F-5F1A1DCA3955/fastlane-snapshotUITests-7A101BFE-7F58-4D72-9725-635F410638C4/Session-fastlane-snapshotUITests-2019-06-16_230212-2h9aTB.log [23:02:12]: ▸ 2019-06-16 23:02:12.138 xcodebuild[69191:7098854] [MT] IDETestOperationsObserverDebug: (4FDA550C-B67C-4979-BF8E-AFF5110B7F9A) Beginning test session fastlane-snapshotUITests-4FDA550C-B67C-4979-BF8E-AFF5110B7F9A at 2019-06-16 23:02:12.138 with Xcode 10B61 on target <DVTiPhoneSimulator: 0x7fa4f4a31420> { [23:02:12]: ▸ SimDevice: iPhone 8 (CE8F6F9C-2A72-4ECF-A3C2-3B4078A479B1, iOS 12.1, Shutdown) [23:02:12]: ▸ } (12.1 (16B91)) [23:02:28]: ▸ All tests [23:02:28]: ▸ Test Suite fastlane-snapshotUITests.xctest started [23:02:28]: ▸ fastlane_snapshotUITests [23:02:35]: ▸ ✓ testExample (6.522 seconds) [23:02:35]: ▸ Executed 1 test, with 0 failures (0 unexpected) in 6.522 (6.524) seconds [23:02:35]: ▸ [23:02:35]: ▸ 2019-06-16 23:02:35.570 xcodebuild[69191:7098854] [MT] IDETestOperationsObserverDebug: 23.496 elapsed -- Testing started completed. [23:02:35]: ▸ 2019-06-16 23:02:35.570 xcodebuild[69191:7098854] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start [23:02:35]: ▸ 2019-06-16 23:02:35.570 xcodebuild[69191:7098854] [MT] IDETestOperationsObserverDebug: 23.496 sec, +23.496 sec -- end [23:02:35]: ▸ Test Succeeded +----------+-------+ | snapshot results | +----------+-------+ | Device | ja-JP | +----------+-------+ | iPhone 8 | ❌ | +----------+-------+ [23:02:41]: Generating HTML Report [23:02:41]: Successfully created HTML file with an overview of all the screenshots: '/Users/*****/Documents/fastlane-snapshot/screenshots/screenshots.html' +------+---------------------+-------------+ | fastlane summary | +------+---------------------+-------------+ | Step | Action | Time (in s) | +------+---------------------+-------------+ | 1 | default_platform | 0 | | 2 | capture_screenshots | 51 | +------+---------------------+-------------+ [23:02:42]: fastlane.tools finished successfully ????

該当のソースコード

Swift

1import XCTest 2 3class fastlane_snapshotUITests: XCTestCase { 4 let app = XCUIApplication() 5 6 override func setUp() { 7 super.setUp() 8 9 continueAfterFailure = false 10 XCUIApplication().launch() 11 } 12 13 func testExample() { 14 let button = XCUIApplication().buttons["testButton"] 15 snapshot("launch") 16 button.tap() 17 } 18}

Snapfile

1# Uncomment the lines below you want to change by removing the # in the beginning 2 3# A list of devices you want to take the screenshots from 4 devices([ 5 "iPhone 8" 6 ]) 7 8 languages([ 9 "ja-JP" 10 ]) 11 12# The name of the scheme which contains the UI Tests 13# scheme("SchemeName") 14 15# Where should the resulting screenshots be stored? 16 output_directory("./screenshots") 17 18# remove the '#' to clear all previously generated screenshots before creating new ones 19 clear_previous_screenshots(true) 20 21# Arguments to pass to the app on launch. See https://docs.fastlane.tools/actions/snapshot/#launch-arguments 22# launch_arguments(["-favColor red"]) 23 24# For more information about all available options run 25# fastlane action snapshot

試したこと

Snapfileのdevicesやlanguagesを変更しましたがスクリーンショットは取れませんでした。

補足情報(FW/ツールのバージョンなど)

fastlane 2.125.2

テスト単体で実行すると成功しているので、テストが失敗していると言うことはなさそうです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

元記事にあるように

Swift

1XCUIApplication().launch()

Swift

1let app = XCUIApplication() 2setupSnapshot(app) 3app.launch()

としましょう。

投稿2019/06/16 16:26

nakasho_dev

総合スコア2655

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

pftyuk

2019/06/17 14:28

ご回答頂きありがとうございます。 ご指摘の箇所を修正したら無事スクリーンショットが取れました。 見落とし失礼致しました・・・。ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問