UI Test for an ios-app, developed in Xcode 8 and swift 3.2.
I'm facing a problem to deal with drag and drop after upgrading Xcode version 8 to 9
I would like to drag an element [i.e. button]
and drop it to another element [i.e. on homepage]
.
For Xcode 8, I implemented it using below method:
let sourceElement = app.buttons["Video_Button"]
let destElement = app.scrollViews.scrollViews.images.element(boundBy: 0)
sourceElement.press(forDuration: 0.5, thenDragTo: destElement)
But the above code is not working in Xcode 9 and Swift 3.2.
Actually issue is in iOS 11.0.
In iOS 11.0 some hierarchical elements failed to tap or press or longpress.
You have to work with the elements center point to do the tap or press or longpress.
** Code snippet for the Solution of the problem is pasted below.
First create an extension method for press on a center of the element and drag this element to the destination elements center.
Extension method is below
Then call the extension method like below
Hope it will solve your issue. Let me know your feedback.