XCUItest - Accessing page content when using deeply nested React Navigation navigators on iOS Using

Hello!

I've been trying to automate tests using Appium/XCUITests in a React Native APP, but I'm finding many blockers. They are related to the amount of nested elements in the "DOM" in which the XCUItest can not go deeper to get all the elements we need.

  • snapshotMaxDepth -> The XCUITest does not support more than 60 value, otherwise it returns the following error:

Got response with status 404: {"value":{"error":"stale element reference","message":"The previously found element "Application 'xyz.xxx.xxx'" is not present in the current view anymore. Make sure the application UI has the expected state. Original error: Error kAXErrorIllegalArgument getting snapshot for element <AXUIElementRef 0x600003aaf750> {pid=95967} {uid=[ID:1 hash:0x0]}","traceback":"(\n\t0 CoreFoundation 0x00007fff20405604 __exceptionPreprocess + 242\n\t1 libobjc.A.dylib 0x00007fff201a4a45 objc_exception_throw + 48\n\t2 WebDriverAgentLib 0x000000010a3caa53 -[XCUIElement(FBUtilities) fb_takeSnapshot] + 723\n\t3 WebDriverAgentLib 0x000000010a3cad07 -[XCUIElement(FBUtilities) fb_snapshotWithAttributes:maxDepth:] + 183\n\t4 WebDriverAgentLib 0x000000010a37baea +[FBXPath writeXmlWithRootElement:indexPath:elementStore:includedAttributes:writer:] + 778\n\t5 WebDriverAgentLib 0x000000010a37b12c +[FBXPath xmlRep...

  • But if I inform less than 60, the XCUITest is not able to get all the elements we need to automate:

There are many threads about this, all of them the issue is in the XCUITest:

We faced this exact same issue on React Native 0.73.7. After trying every suggested workaround (disabling accessibility props, patching the bridge, etc.) with no success, the definitive fix was upgrading to React Native 0.84.0 (New Architecture). The new Fabric rendering engine handles iOS accessibility nodes entirely differently, completely eliminating the 'blobbing' issue for our nested navigators. It works perfectly now.

Note: If you upgrade, be aware of Fabric's "View Flattening" optimization. You may need to add collapsable={false} to any <View> that has a testID to ensure the C++ engine doesn't optimize the view out of the native tree before Appium can find it!

XCUItest - Accessing page content when using deeply nested React Navigation navigators on iOS Using
 
 
Q