There are similar test extensions. I found that what you need to do is click on the element where it is on the screen, and not the element itself, to control the interaction. I have not tested this with my script, but have not yet found anything impossible with this method.
Here is an example of a Swift pushing the βXβ button on a Springboard for an application icon that cannot be used in a similar way with a typical interaction:
let iconFrame = icon.frame // App icon on the springboard let springboardFrame = springboard.frame // The springboard (homescreen) icon.pressForDuration(1.3) // tap and hold // Tap the little "X" button at approximately where it is. The X is not exposed directly springboard.coordinateWithNormalizedOffset(CGVectorMake((iconFrame.minX + 3) / springboardFrame.maxX, (iconFrame.minY + 3) / springboardFrame.maxY)).tap()
Having received a supervisor frame and a preview, you can calculate where the item should be on the screen. Note that coordinateWithNormalizedOffset accepts a vector in the range [0,1], not a frame or pixel offset. Clicking the element itself on the coordinate does not work either, so you must click on the add-in level / XCUIApplication ().
A more generalized example:
let myElementFrame = myElement.frame let appFrame = XCUIApplication().frame let middleOfElementVector = CGVectorMake(iconFrame.midX / appFrame.maxX, iconFrame.midY / appFrame.maxY)
If you need to access the Springboard layer and go beyond the application, you can do this with
let springboard = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.springboard") springboard.resolve()
But you will need to open some private XCUITest methods with Objective-C:
@interface XCUIApplication (Private) { - (id)initPrivateWithPath:(id)arg1 bundleID:(id)arg2; } @interface XCUIElement (Private) { - (void) resolve; }
source share