Xcode - Redact element from Image

60 views Asked by At

Is there a way to redact a particular element from an image in xcode? We are doing snapshot tests and currently we cropping the images where needed or just taking snapshots of particular elements to avoid this issue, but we would like to be able to take an image and redact a certain element that could potentially keep changing like a date/time field.

1

There are 1 answers

0
Roman Zakharov On

You can change the UIImage/NSImage of element (depending on platform)

Read the documentation here https://developer.apple.com/documentation/xctest/xcuiscreenshot/2897658-image


Also, there is a tool SUITCase designed for screenshot testing and capable of cropping elements and erasing dynamic views. https://github.com/devexperts/suitcase/

With SUITCase you can do such verifications:

verifyScreenshot(withoutQuery: app.staticTexts)

enter image description here