[英]How to make UITests-Runner able to access privacy-sensitive data
I'm running an UITests case w/ UIImageWriteToSavedPhotosAlbum()
to save my test screenshot to Photos Album: 我正在运行UITests案例w /
UIImageWriteToSavedPhotosAlbum()
将我的测试截图保存到Photos Album:
- (void)testExample
{
XCUIScreenshot *screenshot = [_app screenshot];
UIImageWriteToSavedPhotosAlbum(screenshot.image, nil, nil, nil);
}
but it crashed w/ error: 但它崩溃了错误:
... XXXUITests-Runner[53905:8592232] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.
... XXXUITests-Runner [53905:8592232] [access]此应用程序已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。 The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.
应用程序的Info.plist必须包含一个NSPhotoLibraryAddUsageDescription键,其中包含一个字符串值,向用户解释应用程序如何使用此数据。
I've provided both NSPhotoLibraryUsageDescription & NSPhotoLibraryAddUsageDescription to my UITest Target & App Target. 我已经为我的UITest目标和应用目标提供了NSPhotoLibraryUsageDescription和NSPhotoLibraryAddUsageDescription。
Searched for a while, I can't figure out a way to let the UITests-Runner able to save image to Photos app so far, no UI level to let me press to allow it. 搜索了一段时间,我想不出办法让UITests-Runner能够将图像保存到照片应用程序到目前为止,没有UI级别让我按下允许它。
So, how can I achieve this, ie, make UITests-Runner able to access privacy-sensitive data (Photos in this case)? 那么,我怎样才能实现这一点,即让UITests-Runner能够访问隐私敏感数据(在这种情况下为照片)?
UITestRunnerIssueDemo UITestRunnerIssueDemo
And below is the related error detail: 以下是相关的错误详细信息:
Test Suite 'All tests' started at 2018-05-10 11:30:37.693
测试套件'所有测试'开始于2018-05-10 11:30:37.693
Test Suite 'UITestRunnerIssueDemoUITests.xctest' started at 2018-05-10 11:30:37.694测试套件'UITestRunnerIssueDemoUITests.xctest'开始于2018-05-10 11:30:37.694
Test Suite 'UITestRunnerIssueDemoUITests' started at 2018-05-10 11:30:37.694测试套件'UITestRunnerIssueDemoUITests'开始于2018-05-10 11:30:37.694
Test Case '-[UITestRunnerIssueDemoUITests testExample]' started.测试用例' - [UITestRunnerIssueDemoUITests testExample]'已启动。
t = 0.00s Start Test at 2018-05-10 11:30:37.695t = 0.00s在2018-05-10 11:30:37.695开始测试
t = 0.05s Set Upt = 0.05s设置
t = 0.06s Open com.kjuly.UITestRunnerIssueDemot = 0.06s打开com.kjuly.UITestRunnerIssueDemo
t = 0.10s Launch com.kjuly.UITestRunnerIssueDemot = 0.10s启动com.kjuly.UITestRunnerIssueDemo
t = 3.08s Wait for com.kjuly.UITestRunnerIssueDemo to idlet = 3.08s等待com.kjuly.UITestRunnerIssueDemo空闲
t = 6.10s Find the Target Application 0x60c0000dd5e0t = 6.10s找到目标应用程序0x60c0000dd5e0
t = 6.25s Tear Downt = 6.25s撕下
2018-05-10 11:30:43.948541+0800 UITestRunnerIssueDemoUITests-Runner[53905:8592232] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.2018-05-10 11:30:43.948541 + 0800 UITestRunnerIssueDemoUITests-Runner [53905:8592232] [access]此应用已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。 The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.
应用程序的Info.plist必须包含一个NSPhotoLibraryAddUsageDescription键,其中包含一个字符串值,向用户解释应用程序如何使用此数据。
Btw, I know I can get the UITests screenshot that auto saved under AppData/Library/Snapshots folder, but it'll be convenient if I can get it from Photos Album, especially when doing so in real device, I'm not willing to download the App Container every time just for getting those screenshots (and also, I need high quality screenshot that saved). 顺便说一句,我知道我可以获得自动保存在AppData / Library / Snapshots文件夹下的UITests截图,但如果我可以从相册中获取它会很方便,特别是在真实设备中这样做时,我不愿意每次下载App Container只是为了获取这些截图(而且,我还需要保存的高质量截图)。
I have exact same issue now, temporary workaround that work for me is to put the image save code: 我现在有完全相同的问题,对我来说工作的临时解决方法是放置图像保存代码:
UIImageWriteToSavedPhotosAlbum(screenshot.image, nil, nil, nil);
inside the app code like when you run it in debug mode. 在应用程序代码中,就像在调试模式下运行它一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.