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?