简体   繁体   中英

How to locate an app to share to in iOS13 share sheet via UI test?

I am using a UI test to check sharing a file to a target app. For that, I am using multi-app UI testing as follows:

  • the target app should become active when sharing a given file to it
  • a helper app UITestsHelper is a simple document-based app template that installs a file in its container, navigates to it and shares the file with the target app

The problem is that, when the share sheet is opened, there is no meaningful text that I can use to find the cell to share the file to the target app, in this case shown as "MyApp".

在此处输入图片说明

When inspecting the UI hierarchy in the logs, this is the relevant section:

ScrollView, {{0.0, 617.0}, {414.0, 132.0}}
  Cell, {{13.0, 617.0}, {78.0, 118.5}}, label: 'AirDrop'
  Cell, {{106.5, 617.0}, {78.0, 118.5}}, label: 'Nachrichten'
  Cell, {{200.0, 617.0}, {78.0, 118.5}}, label: 'Mail'
  Cell, {{293.5, 617.0}, {78.0, 131.5}}, label: 'Aktivität'
  Cell, {{387.0, 617.0}, {78.0, 131.5}}, label: 'Aktivität'

As you can see, system apps and services, such as AirDrop, Messages and Mail have a meaningful label (here in German because that's the system language). Third party apps just show with label "Activity" (Aktivität in German).

I am blindly tapping on the fourth cell right now, as a way to choose the first non-system app, but I find this extremely fragile.

Is there a more reliable way to share aa file to a target app?

I also have found this bug. I workaround it in the next way – I find all this "Activity" cells ( app.cells.matching(identifier: "Activity").allElementsBoundByIndex ) and tap them one after the other until the needed is found (I check it by looking at target app .state )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM