I have an XCUITest that cannot find a specific image, but it is perfectly visible on the screen (emulators and physical devices)
How can I get around or make UIImage available for tests? All I want to check is whether the item is visible and palpable on the screen.
UIImage is added as a subtitle to the UITableView - it is placed at the bottom of the TableView.
- (void)viewDidLoad {
[super viewDidLoad];
_aView = [[UIImageView alloc] initWithFrame:CGRectZero];
[[self aView] setContentMode:UIViewContentModeScaleAspectFit];
[[self aView] setImage:[UIImage imageNamed:IMG_NAME]] ;
[[self tableView] addSubview:[self aView]];
UIImageView later laid out:
- (void) viewWillLayoutSubviews {
[[self aView] setFrame:CGRectMake(0, MAX([self tableView].contentSize.height - 41 ,[self tableView].bounds.size.height - 41) , 180, 30)];
[[self aView] setCenter:CGPointMake([self tableView].center.x, [self aView].center.y)];
Then, when running the test:
let app = XCUIApplication()
let tapString = localizedString("skip")
let skipButton = app.buttons[tapString].firstMatch
if (skipButton.exists) {
skipButton.tap()
}
let theImage = app.images["img.png"]
let doesExist = theImage.exists
Debugging is also performed and printing of all images does not display the image. I set a breakpoint on the line using doExists and in the debug window I run the command:
po app.images
Many images found, but no specific test image.
Is there an alternative to solve this problem?