Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazonアプリストア
Ring
AWS
ドキュメント
Support
Contact Us
My Cases
開発
設計と開発
公開
リファレンス
サポート
メインコンテンツへスキップ
Locator strategies are methods used to find and identify user interface (UI) elements within an app during test automation. These strategies act as search patterns that tell Appium how to locate specific elements on the screen, such as buttons, text fields, or other UI components.

Supported strategies

Appium Vega Driver supports UiSelector and XML Path Language (XPath). This release doesn’t support other selector strategies.

UiSelector

A platform-specific locator strategy that uses the native automation framework to identify UI elements. Prefer UiSelector on Vega: in testing it resolved elements about 10 times faster than the equivalent XPath query, and it’s the only strategy that can scope a lookup to a subtree (see Find an element within a parent). Pass a JSON string with an args object whose keys match the element’s attributes in the UI Component Compositor (UCC) tree. Example usage:

Accepted args keys

Find multiple elements

Use the multi-element form to return every match, then filter in your test code.

Find an element within a parent

To locate a child within a known parent, call the find method on the parent element. This runs a parent-scoped lookup (findElementFromElement). XPath doesn’t work in this position, so UiSelector is the only way to scope a search to a subtree.

XPath

A query language that enables navigation and selection of elements in an XML-like structure. Example usage:

Supported XPath forms

Appium Vega Driver evaluates a single node test with an optional predicate against the app’s element tree. The tree has a <root> element whose descendants are <child> nodes. The driver supports the following forms:
The driver doesn’t support compound or multi-step paths. Avoid the following forms:
To scope a lookup to a subtree, use UiSelector instead of a compound XPath.

Comparison of selector strategies

Best practices

  1. Choose the right strategy
    • Use UiSelector for platform-specific tests
    • Use XPath for cross-platform compatibility
    • Prefer UiSelector when performance is critical
  2. Element location
    • Use unique identifiers when possible
    • Avoid absolute paths
    • Keep selectors as simple as possible
    • Regularly validate selectors’ reliability
  3. Performance considerations
    • Complex XPath queries may impact test execution time
    • Cache frequently used elements
    • Use app-specific IDs when available
  4. Maintenance tips
    • Document locator strategies
    • Review locators regularly
    • Update with UI changes
    • Maintain cross-platform compatibility
    • Use meaningful names in test code

最終更新日 2025年10月31日