@Lu_Lewis, I encountered the same issue when setting up automation for the iOS platform, interactions with elements were significantly slower compared to those on the Android platform.
I addressed this in two key ways. First, I optimized the Appium capabilities for maximum speed. Second, I reduced the size of the iOS page source.
1. Optimizing Appium Capabilities
I discovered several capabilities in the Appium documentation that helped improve performance. Here’s what I added:
"appium:settings[waitForQuiescence]", false
"appium:isHeadless", true
"appium:settings[reduceMotion]", true
"appium:settings[animationCoolOffTimeout]", 0
"appium:settings[customSnapshotTimeout]", 2
"appium:settings[pageSourceExcludedAttributes]", "visible,enabled,accessible,x,y,width,height,index"
2. Reducing the iOS Page Source Size
This step involves adjustments in the app code. Since my project uses React Native, I divided this part into two sub-parts:
- First Sub-Part: Minimizing the @name Attribute
By default, the XCUIElementTypeOther
element in the source tree has its @name
attribute set to include text from all its children recursively. This means the @name
attribute of the first child contains all the text from its child elements, and so on.I realized that I didn’t need this much unnecessary text in the @name
attribute, so I modified it. Here’s how you can do it in your index.js
.
P.S In this code, TEST_IDS.GENERAL_COMPONENTS.VIEW_ID
is set to '_viewId'
.After making this change, your source tree will become much lighter, leading to faster element searches.
View.defaultProps = View.defaultProps || {};
View.defaultProps.testID = TEST_IDS.GENERAL_COMPONENTS.VIEW_ID;
View.defaultProps.accessibilityLabel = TEST_IDS.GENERAL_COMPONENTS.VIEW_ID;
- Second Sub-Part: Checking for Extraneous Elements
Use the Xcode debugger to ensure that only the elements belonging to the current screen are present in the source. For example, if you are on Screen1 and see that elements from Screen2 are also rendered in the source (even though they aren’t visible), it indicates that these elements from Screen2 are being rendered unnecessarily. If you find this issue, you should either adjust the rendering logic yourself or, if you don’t have access to the code, create a ticket for your developers. You might be surprised at how many incorrect renderings you can find in your app, all of which unnecessarily inflate the source tree.
As a result of those manipulations I was able to achieve almost the same test on IOS and Android platforms, Android still is a little faster but not significantly. Hope this will help you.
cc @mykola-mokhnach @Aleksei