如何使用 UIAutomation 从 UIImagePickerController 中选择图像 [英] How to use UIAutomation to select image from UIImagePickerController

查看:19
本文介绍了如何使用 UIAutomation 从 UIImagePickerController 中选择图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试围绕应用程序中的流程进行 UIAutomation 测试,其中用户从 UIImagePickerController 中选择图像.在我们尝试从选取器控制器中选择图像之前,所有的自动化都运行良好.似乎我们无法找到正确的对象来发送水龙头.这是我们正在尝试的:

We are trying to get a UIAutomation test around a flow in our app where a user selects an image from a UIImagePickerController. All the automation works great, until we try to select an image from the picker controller. It seems like we cannot get the right object to send the tap to. Here is what we are trying:

 UIALogger.logMessage("Navigation Title: " + app.navigationTitle() );
 window.collectionViews()[0].tapWithOptions({tapOffset:{x:0.5, y:0.5}});

上面将导航标题显示为时刻",这意味着我们在照片选择器中,但第二行没有错误 - 但没有选择任何东西(无论坐标).

The above will show the navigation title as "Moments", which means we are in the photo picker, but the second line gets no error - but does not select anything (no matter the coordinates).

测试最终失败,卡在照片选择屏幕上.

The test ultimately fails being stuck on the photo selection screen.

我记录了下面的元素树,您可以看到那里似乎有一个 UICollectionView,但所有单元格都是节标题,并且在调试日志输出中没有一个是实际的照片".

I logged the element tree below, and you can see that it appears that there is a UICollectionView out there, but all the cells are the section headers and there are none in the debug log output that are actual 'photos'.

那么我们如何使用 UIAutomation 从 UIImagePickerController 中选择图像?

So how do we select an image from a UIImagePickerController with UIAutomation?

谢谢!

推荐答案

所以,我想通了.呃.我只需要访问可见的单元格并将水龙头发送到其中一个.像魅力一样工作.

So, I figured this out. Duh. I just needed to access the visible cells and send the tap to one of those. Works like a charm.

window.collectionViews()[0].visibleCells()[0].tap();

我希望这对其他人有帮助!

I hope this helps someone else!

这篇关于如何使用 UIAutomation 从 UIImagePickerController 中选择图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆