We are using FBSnapshottestcase to take snapshots as part of our XCUITest cases. We have a ScrollView that has an UITextField. We type text into the text field and take a snapshot to verify the element behaves appropriately with text entered (a clear button appears). The problem we encounter is that when you type into the text field a blinking cursor appears. The tests will fail or pass depending on the state of the blinking cursor when the snapshot is taken. Is there a way to disable the blinking cursor for a XCUITest?
Asked
Active
Viewed 239 times
0
-
end text with / . I think it will remove blink cursor. I had same problem. I forget actual code. let me search – N.. Feb 22 '19 at 19:57
2 Answers
1
The devs added this to the AppDelegate file so that when we are running the test scheme it would do this:
#if LOCAL
if CommandLine.arguments.contains("--UITests") {
UITextField.appearance().tintColor = .clear
}
#endif
This hide the cursor then for the tests.
You can then you
app.launchArguments
to pass "--UITests"
https://developer.apple.com/documentation/xctest/xcuiapplication/1500477-launcharguments

reutsey
- 1,743
- 1
- 17
- 36
0
It is possible to set an optional parameter tolerance
in FBSnapshotVerifyView
call.
For example, if it is set to 0.01
and images are equal by 99% (counting in pixels) or more, then test will not fall.

Roman Zakharov
- 2,185
- 8
- 19