Search code examples
appiumappium-androidandroid-uiautomatoruiautomatorviewer

how to get the correct resource id for an android device from uiautomator?


i have question about resource ids in uiautomator :

btn="id:/image_button_cancel"

why sometimes we add ".*" what is the meaning of that ?

btn="id:/image_button_cancel.*"

Solution

  • It is a regular expression. The dot means any character and the asterisk means zero or more repetitions.

    So using btn="id:/image_button_cancel.*" will match any resource id that starts with "id:/image_button_cancel".

    Example (matched ids):

    id:/image_button_cancel
    id:/image_button_cancel_action
    

    Example (not matched ids):

    id:/cancel
    id:/image_button
    

    Search about regex to understand it better.