问题描述
如何在XCUITest中访问UIActivityViewController(共享/操作表)?根据Accessibility Inspector的说法,t由多个UICollectionViews组成,这使得很难对工作表本身进行歧义消除.
How do you access a UIActivityViewController (share / actions sheet) in XCUITest? According to the Accessibility Inspector, t is comprised of several UICollectionViews, which makes it hard to disambiguate the sheet itself.
查询 XCUIApplication().sheets.count
会在表单出现时返回 0
.
Querying for XCUIApplication().sheets.count
returns 0
when the sheet is presented.
推荐答案
事实证明,当使用视图调试器时,可以通过 ActivityListView
的某种隐藏的accessibilityIdentifier来访问工作表(自Xcode 9.2起)).可以通过以下方式访问它:
It turns out, when using the view debugger, the sheet is accessible via a somewhat hidden accessibilityIdentifier of ActivityListView
(as of Xcode 9.2). It can be accessed with:
XCUIApplication().otherElements["ActivityListView"]
请注意,取消"按钮是单独添加到窗口中的,因此它不是活动控制器的子级,必须使用来访问
Note that the "Cancel" button is added to the window separately, so it not a child of the activity controller and must be accessed with
XCUIApplication().buttons["Cancel"]
这篇关于XCUITest和UIActivityViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!