Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCUITest and UIActivityViewController

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.

like image 317
Chase Holland Avatar asked Jan 23 '26 10:01

Chase Holland


1 Answers

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"]
like image 176
Chase Holland Avatar answered Jan 26 '26 02:01

Chase Holland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!