Appium Find Element Insights

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.