When using Appium to test the app is not selenium so good, why?
Personally, because the positioning method is too small, the XPath in selenium is strong enough to find almost any element.
But in the Appium XPath is not good, and often is a long string, ineffective. Basic use resource_id to locate, then the problem comes, no resource_id how to do, with Content-desc, this is a help the blind use of things, can use find_element_by_accessibility_id to locate, So the question comes again. What if there's a space line break in this content-desc? How to use something like contains in XPath to locate it? Here's the idea of finding a group that contains the element you're looking for by class_name, by traversing through each element and judging whether the element's Get_attribute (' name ') contains a keyword to determine if it's the element we're looking for.
elements = driver.find_elements_by_class_name (' xxx '):
For element in elements:
If key in Element.get_attribute (' name '):
print ' element find '
However, one problem must be explained that the next Get_attribute (' name ') is likely to return CONTENT-DESC, and it is possible to return text, in general, if there is no Content-desc, the text will be returned
Appium Find Element Insights