UIATarget captureScreenWithName() 的 XCUIApplication 替换 [英] XCUIApplication replacements for UIATarget captureScreenWithName()

查看:35
本文介绍了UIATarget captureScreenWithName() 的 XCUIApplication 替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试从 UIAutomation 迁移到 XCUITests,并且确实使用了 captureScreenWithName() API 以编程方式生成屏幕截图.XCUITests 中的替代品是什么?(我知道在出现错误时会自动截取屏幕截图,但是我们有一个特殊的测试,它会永远循环运行,并通过类似于 appium-xcuitest-driver https://github.com/appium/appium-xcuitest-driver)我是否需要像 appium 开发人员那样撕掉私有头文件 (XCAXClient_iOS.h) 才能获得屏幕截图 API?

We are trying to migrate from UIAutomation to XCUITests and did use the captureScreenWithName() API to programmatically generate screen shots. What is the replacement in the XCUITests ? (I know that automatically screenshots are taken in case of error, but we have a special test which runs forever in a loop and evaluates QA click,tap commands via network similar to the appium-xcuitest-driver https://github.com/appium/appium-xcuitest-driver) Do I need to rip out private headers (XCAXClient_iOS.h) like the appium guys did in order to get a screenshot API?

编辑我将实际代码行用于接受的解决方案https://github.com/fastlane/fastlane/blob/master/snapshot/lib/assets/SnapshotHelper.swift 和它只是 IOS

Edit I used the actual code line for the accepted solution from https://github.com/fastlane/fastlane/blob/master/snapshot/lib/assets/SnapshotHelper.swift and its just this for IOS

 XCUIDevice.sharedDevice().orientation = .Unknown

或在 objC 中

[XCUIDevice sharedDevice].orientation =UIInterfaceOrientationUnknown;

我使用主机上的一个进程在Logs/Test/Attachments"目录中查找调用前的所有 Screenshot_*.png 文件,然后在调用后找到新的镜头作为添加到此目录中的新文件.

I use a process on the host to lookup in the "Logs/Test/Attachments" directory all Screenshot_*.png files before the call , and find the new shot then after the call as the new file added in this directory.

推荐答案

手势(点击、滑动、滚动...)会导致截屏,并且在定位元素或评估期望时也经常截取屏幕截图.

Gestures (taps, swipes, scrolls...) cause screenshots, and screenshots are also often taken while locating elements or during assessing expectations.

Fastlane 的快照工具使用旋转到未知方向来触发截图事件(对应用程序没有影响):https://github.com/fastlane/fastlane/tree/master/snapshot - 如果你想控制一些截图,你可以使用它.

Fastlane's snapshot tool uses a rotation to an unknown orientation to trigger a screenshot event (which has no effect on the app): https://github.com/fastlane/fastlane/tree/master/snapshot - you can use this if you want to be in control of some screenshots.

这篇关于UIATarget captureScreenWithName() 的 XCUIApplication 替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆