A small tip to reduce iOS App automation execution time in Appium

 Everyone knows that XPATH is very time-consuming, specially when used in Appium, some times they take more than 3 seconds to find the locator.

If you don't believe me, then take a look at the attached video. Observe the time taken by Xpath vs iOS Predicate and decide yourself.

Hence, I started looking for an alternative. 

Please note that this TIP is only applicable for iOS. Instead of using XPATH, if you use iOS Predicate, it will save your time a lot. IOS predicates are very easy to use as they also worked on attributes, just like XPATH, just that their syntax is different from XPath



For example

driver.findElementByXPath('//XCUIElementTypeTable[@name="table"]');
//will translate to:
driver.findElementByIosNsPredicate('type == "XCUIElementTypeTable" AND name == "table"');


driver.findElementByXPath('//XCUIElementTypeTable[@name="table" or @label="tableLabel"]');
//will translate to:
driver.findElementByIosNsPredicate('type == "XCUIElementTypeTable" AND (name == "table" OR label == "tableLabel")');



* Above examples taken from 

https://developers.perfectomobile.com/display/TT/Finding+Elements+on+XCUITest+devices


Comments

Popular posts from this blog

How to mock a response in Selenium

Some useful links for testing

Generic Checklist in case you want to consider Cypress