You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letscreenshot=XCUIScreen.main.screenshot()letattachment=XCTAttachment(screenshot: screenshot)
attachment.lifetime =.keepAlways
attachment.name = name
add(attachment)
Screenshot capturing happens after the action, so it may be too late. One way is to inject launch arguments, like app.launchArguments.append("--dragdrop") to alter some code in the app.
We can also swizzle gesture recognizer to alter behavior
extensionUILongPressGestureRecognizer{@objcvaruiTests_state:UIGestureRecognizer.State{letstate=self.uiTests_state
if state ==.ended {return.changed
}else{return state
}}}letoriginalSelector= #selector(getter: UILongPressGestureRecognizer.state)letswizzledSelector= #selector(getter: UILongPressGestureRecognizer.uiTests_state)letoriginalMethod=class_getInstanceMethod(UILongPressGestureRecognizer.self, originalSelector)!
letswizzledMethod=class_getInstanceMethod(UILongPressGestureRecognizer.self, swizzledSelector)!
letdidAddMethod=class_addMethod(UILongPressGestureRecognizer.self, originalSelector,method_getImplementation(swizzledMethod),method_getTypeEncoding(swizzledMethod))
if didAddMethod {class_replaceMethod(UILongPressGestureRecognizer.self, swizzledSelector,method_getImplementation(originalMethod),method_getTypeEncoding(originalMethod))}else{method_exchangeImplementations(originalMethod, swizzledMethod)}
The text was updated successfully, but these errors were encountered:
In UITests, we can use
press
fromXCUIElement
to test drag and dropand then take screenshot
Screenshot capturing happens after the action, so it may be too late. One way is to inject launch arguments, like
app.launchArguments.append("--dragdrop")
to alter some code in the app.We can also swizzle gesture recognizer to alter behavior
The text was updated successfully, but these errors were encountered: