Skip to content

Is Element Exist

Summary

  • Internal name: IsElementExist
  • Category: Android UI
  • Purpose: Check whether an element matching a selector is currently on screen. Branches the workflow - true if found, false otherwise.
  • Task type: Condition

Compatibility

  • Minimum AndroMate version: 1.1.0
  • Maximum AndroMate version: 1.1.0
  • Minimum Android: Android 13 (API 33)
  • Maximum Android tested: Android 16 (API 36)
  • Supported manufacturers:

    • Samsung (One UI 6.x / 7.x / 8.x)
    • Other manufacturers - not supported yet (Xiaomi HyperOS and Google Pixel are being adapted)
    • Required permissions:
    • ACCESSIBILITY_SERVICE

Detailed description

The Is Element Exist task performs a single, immediate check of the accessibility tree for an element matching a selector, and branches the workflow accordingly - unlike the action tasks in this group (Click In Element, Fill Text, ...), a "not found" result here is a normal outcome (the false branch), not a thrown exception. This is what makes it a Condition task rather than a Normal one.

The search is not limited to clickable nodes - it can detect any element, matching the same rule used by Wait For Element and Scroll To Element, just without the polling loop.


Input parameters

Parameter Type Required Possible values Android Compatibility AndroMate Compatibility Default
IsElementExist_textSelector Enum / String (resolvable) Yes text, contentDescription, tooltipText, resourceId, className, hintText, anyOf Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""
IsElementExist_CompareType Enum / String (resolvable) Yes exactText, startWith, contain Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""
IsElementExist_Index Integer (resolvable) No 0-based index among matches Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 0
IsElementExist_matchText String (resolvable) Yes The value to match against Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""

Output parameters

This is a Condition task - it does not store a value. Instead, it directs workflow execution:

Condition Next step
An element matching the selector is found true branch
No matching element is found false branch

Exceptions

Code Exception Name Description
SCREEN-AUTOMATOR-ERROR-006 Unsupported Text Selector IsElementExist_textSelector isn't a recognized selector value.
SCREEN-AUTOMATOR-ERROR-010 Screen Automator Service Not Connected The AndroMate accessibility service isn't enabled/connected.

Note: an element simply not being present is not an error - it's the false branch.


Execution flowchart

flowchart TD
    Start([IsElementExist]) --> CheckConnected{Accessibility service\nconnected?}
    CheckConnected -->|No| E1[SCREEN-AUTOMATOR-ERROR-010\nSERVICE_NOT_CONNECTED]
    CheckConnected -->|Yes| Search["Search accessibility tree\n(any node)"]
    Search --> Found{Match found?}
    Found -->|Yes| TrueBranch([true branch])
    Found -->|No| FalseBranch([false branch])

    E1 --> Error([Exception])

    style Start fill:#e3f2fd
    style TrueBranch fill:#c8e6c9
    style FalseBranch fill:#ffcdd2
    style Error fill:#ffcdd2
    style Search fill:#f3e5f5

How it works:

  1. Check connection: fails fast with SERVICE_NOT_CONNECTED if the accessibility service isn't enabled.
  2. Search once: looks anywhere in the tree for a match against IsElementExist_matchText, no polling.
  3. Branch: true if found, false otherwise.

Code examples

Example 1 - Check whether a "Skip" button is present

{
  "IsElementExist": [
    {
      "id": "1",
      "title": "Is Skip button present?",
      "IsElementExist_textSelector": "text",
      "IsElementExist_CompareType": "exactText",
      "IsElementExist_Index": 0,
      "IsElementExist_matchText": "Skip"
    }
  ]
}

Input parameter details

1. Input parameter: IsElementExist_textSelector

Same 7 values as Click In Element > ClickInElement_textSelector, including anyOf.

Example

"IsElementExist_textSelector": "text"

2. Input parameter: IsElementExist_CompareType

exactText, startWith, or contain (case-insensitive).

Example

"IsElementExist_CompareType": "exactText"

3. Input parameter: IsElementExist_Index

If multiple elements match, selects the n-th one (0-based) - mostly relevant with contain/startWith.

Example

"IsElementExist_Index": 0

4. Input parameter: IsElementExist_matchText

The value to match against.

Example

"IsElementExist_matchText": "Skip"

Output parameter details

This is a Condition task - it stores no output variable. The result drives the workflow branching:

true branch

Taken when an element matching the selector/compare/index is currently on screen.

false branch

Taken when no such element is found.


Complete JSON example

{
  "IsElementExist": [
    {
      "id": "1",
      "title": "Is Skip button present?",
      "IsElementExist_textSelector": "text",
      "IsElementExist_CompareType": "exactText",
      "IsElementExist_Index": 0,
      "IsElementExist_matchText": "Skip"
    }
  ]
}