如何使用 UIAutomation 从 UIImagePickerController 获取 select 图片

How to use UIAutomation to select image from UIImagePickerController

我们正在尝试围绕我们应用程序中的一个流程进行 UIAutomation 测试,其中用户 select 从 UIImagePickerController 获取图像。所有的自动化工作都很好,直到我们尝试 select 来自选择器控制器的图像。似乎我们无法获得正确的 object 来发送点击。这是我们正在尝试的:

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

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

测试最终失败被卡在照片上selection screen。

我记录了下面的元素树,你可以看到那里似乎有一个 UICollectionView,但是所有的单元格都是 headers 部分并且调试中有 none实际的日志输出 'photos'.

那么我们如何 select 来自带有 UIAutomation 的 UIImagePickerController 的图像?

谢谢!

所以,我想通了。呃。我只需要访问可见单元格并将水龙头发送到其中一个单元格。很有魅力。

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

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

我通过

解决了这个问题
app.tables.cells.element(boundBy: 1).tap()  
// this table has two rows // 1- Moments  // 2- Camera role
app.collectionViews["PhotosGridView"].cells["Photo, Landscape, January 11, 6:34 PM"].tap() // I want to select this item from moments

正在运行。

首先,我选择动态行,然后 select 照片。稍后我单击按钮选择以确认选择的图像。

    let moments = app.tables.cells.element(boundBy: 0)
    moments.tap()
    sleep(3)
    let selectedPhoto = app.collectionViews.element(boundBy: 0).cells.element(boundBy: 0)
    sleep(3)
    selectedPhoto.tap()
    sleep(3)
    //Choose Button
    let chooseButton = app.buttons.element(boundBy: 1)
    chooseButton.tap()

希望对您有所帮助