Yes it is possible.
Using XCUIApplication
XCUIApplication has a minimal API, but several methods require special attention:
-launch - By default, the new XCTestCase Templates include a line in -setup, which creates a new XCUIApplication and starts it. When -launch is called, it terminates any previously running instance of the target application. This means that by default, every test case you add will restart your application before each test method. You can avoid this by using the generic link to the special XCUIApplication that you -launch only once, but aside from the total test time, there are not many advantages to doing this.
-launchEnvironment - Allows you to control the variables of the custom environment passed to the target application at startup. This can be used to (among other things) configure a user variable that your application can use to identify when it is running as a target for automatically testing the user interface. Although this may be useful, it should be used wisely. Your user interface tests are not very useful if they do not implement the same code as your users.
User interface entry
Using Xcode 7, Apple added a βRecord User Interface Testβ button, which allows you to execute your user interface and record these actions in any current test case method that you are editing. Although this sounds great in theory, in practice, I have found that its current implementation is erroneous and unreliable. Here are some tips for using it:
Move to Slow-Motion. - Performing your clicks and keystrokes too fast or in quick succession may cause some of them to be skipped by Xcode
Expect errors - recording in some cases simply does not work. Clicking the Do Not Save button in the NSSavePanel will write a string with an Unicode escaped character that does not work. In many cases, recording will end with a general error message, as shown below. Sentence? Use the record sparingly as a starting point for writing test cases from scratch.

user7834552
source share