Skip to content

Fill Text

Summary

  • Internal name: FillText
  • Category: Android UI
  • Purpose: Find an editable element by selector and fill it with a text value.
  • Task type: Normal

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 Fill Text task locates an element by selector and sets its text via AccessibilityNodeInfo.ACTION_SET_TEXT - no on-screen keyboard involved. Unlike Click In Element, the search is not limited to clickable nodes, since an editable field isn't always reported as clickable by the accessibility tree; this makes hintText (the field's placeholder) a particularly useful selector here, since an empty field has no text yet to match on.

Does not wait for the element to appear - pair with Wait For Element beforehand if the field may not be on screen yet.


Input parameters

Parameter Type Required Possible values Android Compatibility AndroMate Compatibility Default
FillText_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 ""
FillText_CompareType Enum / String (resolvable) Yes exactText, startWith, contain Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""
FillText_Index Integer (resolvable) No 0-based index among matches Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 0
FillText_matchText String (resolvable) Yes The value used to locate the field Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""
FillText_value String (resolvable) Yes The text to type into the field Android 13 (API 33) -> Android 16 (API 36) 1.1.0 -> 1.1.0 ""

Output parameters

This task produces no output variable. It returns a VoidResult on success.


Exceptions

Code Exception Name Description
SCREEN-AUTOMATOR-ERROR-006 Unsupported Text Selector FillText_textSelector isn't a recognized selector value.
SCREEN-AUTOMATOR-ERROR-010 Screen Automator Service Not Connected The AndroMate accessibility service isn't enabled/connected.
SCREEN-AUTOMATOR-ERROR-011 Screen Automator Action Failed No matching element was found, or ACTION_SET_TEXT was refused by the target - includes the resolved selector/compare/index/matchText in the error detail.

Execution flowchart

flowchart TD
    Start([FillText]) --> CheckConnected{Accessibility service\nconnected?}
    CheckConnected -->|No| E1[SCREEN-AUTOMATOR-ERROR-010\nSERVICE_NOT_CONNECTED]
    CheckConnected -->|Yes| Search["Search accessibility tree\n(any node, no clickable filter)"]
    Search --> Found{Match found?}
    Found -->|No| E2[SCREEN-AUTOMATOR-ERROR-011\nACTION_FAILED]
    Found -->|Yes| SetText[ACTION_SET_TEXT\nwith FillText_value]
    SetText --> Result{Returned true?}
    Result -->|No| E2
    Result -->|Yes| Success([VoidResult])

    E1 --> Error([Exception])
    E2 --> Error

    style Start fill:#e3f2fd
    style Success fill:#c8e6c9
    style Error fill:#ffcdd2
    style SetText fill:#fff9c4
    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: looks anywhere in the tree (not just clickable nodes) for a match against FillText_matchText.
  3. Fill: performs ACTION_SET_TEXT with FillText_value; not found, or a refused action, raises ACTION_FAILED.

Code examples

Example 1 - Fill a username field by its hint text

{
  "FillText": [
    {
      "id": "1",
      "title": "Enter username",
      "FillText_textSelector": "hintText",
      "FillText_CompareType": "contain",
      "FillText_Index": 0,
      "FillText_matchText": "Username",
      "FillText_value": "andromate_user"
    }
  ]
}

Input parameter details

1. Input parameter: FillText_textSelector

Where the matched text (used to locate the field) is read from - see Click In Element > ClickInElement_textSelector for the full value list (same 7 values, including anyOf).

Example

"FillText_textSelector": "hintText"

2. Input parameter: FillText_CompareType

How the comparison is performed (case-insensitive): exactText, startWith, or contain.

Example

"FillText_CompareType": "contain"

3. Input parameter: FillText_Index

If multiple elements match, selects the n-th one (0-based).

Example

"FillText_Index": 0

4. Input parameter: FillText_matchText

The value compared against the selector to find the field - not the value typed into it (that's FillText_value).

Example

"FillText_matchText": "Username"

5. Input parameter: FillText_value

The text actually written into the field once found.

Example

"FillText_value": "andromate_user"

Output parameter details

This task has no output parameters.


Complete JSON example

{
  "FillText": [
    {
      "id": "1",
      "title": "Fill password field",
      "FillText_textSelector": "resourceId",
      "FillText_CompareType": "contain",
      "FillText_Index": 0,
      "FillText_matchText": "password_input",
      "FillText_value": "S3cret!"
    }
  ]
}