How to properly UITest application with UIImagePickerController (or any other native VC)

I am trying to automate the creation of screenshots of my application using Snapshot , and everything is going fine until I want to navigate a UIImagePickerController , which set allowsEditing to true .

Itโ€™s strange that on iPhone 4s, 5s and 6s simulators this works fine, but on iPhone 6 (s) Plus the test doesnโ€™t seem to be able to use โ€œSelectโ€ (โ€œKiesโ€ in Dutch) in the crop view.

VDH0M.jpg

My first attempt did not work in any version:

 app.buttons.elementBoundByIndex(2).tap() 

And this led to the following error:

file: ///% 3Cunknown% 3E: test error: - [MyAppSnapshots testExample ()] failed: user interface testing error - failed to scroll to visible (using the AX action). Button 0x7f82d450ae30: traits: 8589934593, {{327.0, 613.5}, {35.0, 34.0}}, label: "Kies", error: error -25204, executing AXAction 2003

Then from this answer, I grabbed the forceTapElement solution, which works on all but iPhone 6 (s) Plus.

 app.buttons.elementBoundByIndex(2).forceTapElement() 

Then I tried to click on the coordinate;

 let window = app.windows.elementBoundByIndex(0) let rightBottom = window.coordinateWithNormalizedOffset(CGVectorMake( CGRectGetWidth(window.frame) - 20, CGRectGetHeight(window.frame) - 20 )) rightBottom.tap() 

But this again did not work on any of the devices.

So how do I check these interfaces? Or should I just add some kind of switch to my code so that the UIImagePickerController replaced with something non-interactive.

+5
source share

Source: https://habr.com/ru/post/1242622/


All Articles