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

查看:228
本文介绍了如何使用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}});

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

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'.

那么我们如何从UIIutoPickerController中选择UIAutomation的图像?

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天全站免登陆