XCUITest and UIActivityViewController

自闭症网瘾萝莉.ら 提交于 2020-01-12 10:54:28

问题


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.

Querying for XCUIApplication().sheets.count returns 0 when the sheet is presented.


回答1:


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"]


来源:https://stackoverflow.com/questions/48450561/xcuitest-and-uiactivityviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!