問題描述
我們正在嘗試圍繞應用程序中的流程進行 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 中選擇圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!