XCUITest is failing to detect some Images


I’ve got a Xamarin app to test - one of its pages shows a list of something called Activity. On each row of the list - there’s an icon signifying what sort of an ‘Activity’ it is - and some text information about it. The test cases I’m trying to automate involve looking at the Icon to figure out the type of Activity it is - and whether it’s read or not.

On Android version of this app - I was easily able to grab said icon using UIAutomator2 and do Screenshot comparison for it.
But no such luck with iPhone version of the app and XCUITest - seems like the driver is simply Unable to detect each and every icon:

Screenshot 2023-09-08 at 12.13.56 PM.png

It can detect icons on some other pages, but not this one. I don’t really even know who to turn to - is it apple that’s failing here?

Xamarin code for generating these icons seem really simple:

<Image HorizontalOptions=“Center”
effects:IconDecoration.IconSource="{Binding Icon}"
effects:IconDecoration.NullOrYCheck="{Binding MessageId,Converter={StaticResource ActivityReadConverter}}"
effects:IconDecoration.TintColor="{DynamicResource UnreadIconColor}"
effects:IconDecoration.NotNullOrYTintColor={DynamicResource ReadIconColor}"
Source="{Binding Icon}">
<Image.GestureRecognizers>…stuff here for marking it read when tapped I guess… </Image.GestureRecongnizers>

While the following Xamarin code on a different page results in Icons that XCUITest seems to recognize:

So… what’s breaking it? Why can’t XCUITest see those icons? Am I forced to completely redesign my test cases?

you need to make sure elements (icons in this case) are accessible. Perhaps, check the Xamarin tutorial on accessibility.

1 Like