[英]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.我正在使用 UI 测试来检查将文件共享到目标应用程序。 For that, I am using multi-app UI testing as follows:为此,我正在使用 多应用程序 UI 测试,如下所示:
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辅助应用UITestsHelper
是一个简单的基于文档的应用模板,它在其容器中安装一个文件,导航到该文件并与目标应用共享该文件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".问题是,当共享表打开时,没有有意义的文本可用于查找将文件共享到目标应用程序的单元格,在这种情况下显示为“MyApp”。
When inspecting the UI hierarchy in the logs, this is the relevant section:检查日志中的 UI 层次结构时,这是相关部分:
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).如您所见,系统应用程序和服务,例如 AirDrop、Messages 和 Mail,都有一个有意义的标签(这里是德语,因为这是系统语言)。 Third party apps just show with label "Activity" (Aktivität in German).第三方应用程序仅显示带有“活动”标签(德语为 Aktivität)。
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.我也发现了这个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
)我用下一种方法解决它 - 我找到所有这些“活动”单元格( app.cells.matching(identifier: "Activity").allElementsBoundByIndex
)并一个接一个点击它们,直到找到需要的(我通过查看在目标应用程序.state
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.