Record UI tests in Xcode

In a previous article I gave a short introduction into UI testing with Xcode. It works fine, but sometimes it’s a bit complicated to learn how to interact with the ui elements. This video shows by example how the recording feature helps with this problem.

Demo: Record UI interaction

How to record UI tests

To start the ui test recording press the red button in the toolbar below the editor. The app starts and every interaction will be added as code into the current function.



The generated code should be refactored and cleaned up. Test code, especially ui test code must stay maintainable, because it will break on ui changes that will occur. Remove duplication and make it more readable just like your production code.

Be aware, that the recording does not detect all interactions correctly. So it’s better to record in small steps and see if the generated code does what you expect.
If not it’s usually easier to modify the generated code than searching how to access (a more complex) element without a starting point. I haven’t found an official documentation, but there’s  a good reference and cheat sheet on that can help.


The recording feature is not a wizard, that does all the work for you – It’s just an assistant. The generated code is a good starting point for a coded UI test, to understand how to get a value or a state of an element.

See more: Xcode iOS UI testing.