简体   繁体   English

如何通过 UI 测试在 iOS13 共享表中找到要共享的应用程序?

[英]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 测试,如下所示:

  • 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辅助应用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.

相关问题 iOS13上带有自定义标题+远程图像的共享表 - Share Sheet with custom title + remote image on iOS13 iOS13分享表:分享UIImage时如何设置预览缩略图 - iOS13 share sheet: how to set preview thumbnail when sharing UIImage 如何在 ios13 中禁用 pdfkits pdfview 中的查找、共享、转发菜单项 - How to disable look up, share, forward menu items in pdfkits pdfview in ios13 如何通过iOS应用程序将URL分享给linkedIn - How to share a URL to linkedIn via iOS app 如何在 iOS UI 测试中定位系统操作表上的元素 - How to locate element on system action sheet in iOS UI Test 如何通过网站为 iOS 共享表设置缩略图? - How to set thumbnail for iOS share sheet via website? iOS-在UI测试和应用之间共享实例/内存 - iOS - share instances / memory between UI test and app iOS13中的Action sheet UI问题,无法自定义消息和边框线 - Action sheet UI issues in iOS13, unable to customise message and the border lines 快速重新创建 iOS 13 的共享表模式(不是共享表本身,而是它的呈现方式) - Recreate iOS 13' share sheet modal in swift (not the share sheet itself, but the way it's presented) iOS 13 共享表:更改副标题/项目描述 - iOS 13 Share Sheet: Changing subtitle/item description
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM