On iPhone 6 (and smaller) the phone never displays a split view in "expanded" mode. That is, the primary and secondary view controllers inside the split view are always shown sequentially. In contrast, on iPhone 6Plus (and larger) the phone will show split views in expanded mode when in landscape orientation. That is, the primary and secondary view controllers are shown side-by-side.
This creates a problem for UI Tests. When the device is a phone and the horizontal size class is Compact (iPhone 6 and smaller) then there should have one set of tests. When the device is a phone and the horizontal size class is Regular then there should be a separate set of tests.
Unfortunately, I haven't been able to discover a test for size classes when dealing with UIElements in UITests. Is there a way to get traitCollection information when performing UI Testing?
The UIDevice object has a "model" property. This is a string. When testing on the Simulator the only values I have seen from this property is "phone" or "pad". A phone's model-number does not seem to be available and Apple's documentation does not guarantee any particular value.
The UIDevice object also has a userInterfaceIdiom property. This enum can report things like CarPlay and Apple TV in addition to pad and phone, but again does not return any model-number information.
XCUIDevice does not report either trait environment or model-number.
My work-around is to insert test code inside my main project. In the opening scene I give one of the elements an accessibility identifier that reflects the initial horizontal size class. If there is a title, for example then the accessibility identifier become "title (compact)" or "title (regular)". This can be interrogated in UI Tests during setup and a global variable can be set for later use. It is a pretty poor kludge, however.
I'm hoping that someone knows of an object (accessible in UI Tests) that will return something like:
<some object>.supportsSplitViewInExandedMode
That would be great!