element.findElements() is slower than driver.findElements() in Appium for IOS

Background : I am automating a react native ios application. The pages are heavy. So, some findElement() call is even taking around 40 seconds despite using ios class chain. So, my aim is to reduce the findElement time.

I had to identify a tab list. I compared the time taken between finding elements of the tab directly and finding elements of the tab using their parent element.

PFB my XML page source excerpt:


Method 1: I used this locator and find the elements:

By byTabList = MobileBy.iOSClassChain("**/XCUIElementTypeOther[`name BEGINSWITH[c] 'General Pricing Options Damages'`][-1]/XCUIElementTypeOther");
.
.
driver.findElements(byTabList);

Method 2: I split the above into two.

By byTabContainer = MobileBy.iOSClassChain("**/XCUIElementTypeOther[`name BEGINSWITH[c] 'General Pricing Options Damages'`][-1]");
By byTabList = MobileBy.iosClassChain("XCUIElementTypeOther");
.
.
WebElement tabContainer = driver.findElement(byTabContainer);

tabContainer.findElements(byTabList);

I logged the time taken by them through appium terminal. PFB image:

I repeated the process 3 times and compared the time taken by them. PFB the table:

Final outcome : element.findElements() is 3 seconds slower than driver.findElements().

My question is, when we look for an element using another element, we are restricting its focus to that element’s contents instead of whole page source which should ideally improve the performance, right? Why am I not seeing any performance improvement? Am I doing anything wrong?

If this won’t work, is there any other way to improve the performance?

If you page is large and you have many elements outside screen on it = you will have slow elements find on iOS. It was faster before ios 13.1. Then is became 50-80% slower. And now with latest 13.4.1 speed a bit improved.

It will help a bit if you ask ios developer to put accessibilityIdentifiers (element ids) for tab and it elements.

Also it will help if you reduce amount of data on screen (e.g. instead of 100 elements in list will be 25).

1 Like

Thanks Aleksei for the comment. Neither putting the accessibility identifier nor reducing amount of data on screen is in my hand. So, I need to look for other possbilities.

Can you please let me know what went wrong in the above approach and anything could be done to improve the performance in this scenario?

“name” attribute is actually id. Try your text as id.