Can I have an alternative way to find element by accessibilityId?
Because my company application is an old, the application does't have Ids (Android: resource-id, iOS: accessibilityId).
So it is a huge impact for me that I can't find elements by name locator.
Probably I need to modify test codes from "name" to "xpath" if I want to update Appium@1.5.0?
My bandage solution for working around By.name was using this xpath expression: //*[@name='name']
I don't have insight into the reasons behind deprecating the name strategy early with Appium 1.0, but I guess it has something to do with the fact that the name strategy's Selenium documented and intended behavior did not match with the behavior of Appium's name strategy.
Look this tutorial68
Appium samples you can find here41
Appium documentation47
Really a lot of topics how start work with appium you can find in google.
you can also follow some basic examples like this23 and then let us know in this forum, if you are struck up somewhere.
This is a valid question @jlipps @penguinho @jonahss, because in lots of apps (probably most of them) devs do not apply ids on all elements and using xpath does not seem a good alternative.
Can you post why this happened and if there is any other alternative besides xpath?
Thanks
Xpath is a completely viable solution, and in fact allows you to continue using "name".
I have been doing ALL of my Appium development using xpath exclusively and successfully. But I'm forced to do this as my AUT doesn't currently have accessibility IDs at this time. So visible text is my only unique identifier I can rely on. And some don't even have "name" attribute (protected password entry fields, for example). Thus xpath to the rescue.
locators["settings.security_notifications_slider_label"] = '//UIAStaticText[@name="Security Notifications"]'
The reason people jump to saying "xpath is bad, never use xpath" is when they're composing horribly brittle xpath based on meaningless nested indexes like:
'//UIATableGroup[2]/UIATableCell[7]/UIAStaticText[4]'
Better yet xpath allows you to find elements based on specific relationships in the page source using xpath axes.
locators["cases_and_contracts.special_all_open_cases"] = \
'//UIATableGroup[@name="SPECIAL"]/following-sibling::UIATableCell[@name="All Open Cases"]'
So go explore xpath, I think you'll find it a functionally successful method of locating your elements.
Agree with @Christopher_Graham.
Xpaths provides many more options to solve a complicated locator issue.
+ I agree with @Christopher_Graham and @Mayuresh_Shirodkar, Once you know your way around with XPath, You never get stuck for locator issue.
@Christopher_Graham 200% agree with your comments.
Majority of engineers don't know how to build "rock solid" xpath and keep blaming this nice strategy.