Logo : Entering Text

Entering Text

Communauté
skydoves
entering-text

Utilisez cette compétence pour piloter les champs de texte Jetpack Compose depuis des tests avec les actions dédiées au texte : performTextInput (insère au niveau du curseur via l’action sémantique InsertTextAtCursor), performTextReplacement (efface puis remplace via SetText), performTextClearance (remplace par une chaîne vide), performTextInputSelection (définit la sélection TextRange) et performImeAction (déclenche l’action IME configurée, comme Next, Done ou Search). Elle couvre le parcours de mise au point automatique, les prérequis enabled / editable / focusable, le piège de l’ajout au lieu du remplacement, qui produit « helloworld » au lieu de « world », ainsi que la chaîne de mise au point des actions IME (Next déplace le focus vers l’élément suivant pouvant recevoir le focus). Utilisez-la si le développeur demande « comment saisir du texte dans un TextField pendant un test », « tester un bouton IME Next », « tester une action d’effacement du texte », « BasicTextField n’accepte pas la saisie », « la saisie de texte est dupliquée pendant le test », ou signale des erreurs « Failed to perform text input » / « Failed to perform IME action » / « Default ImeAction ».

Add to TypingMind

Présentation

Éditeurskydoves
Dépôtandroid-testing-skills
Nom de la compétenceentering-text
Étoiles
338
Forks
14
Fichiers inclus
Instructions uniquement
LicenceApache-2.0
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont rédigées en Markdown et non sous forme de code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • Tout dans les instructions

    Tout ce dont le modèle a besoin se trouve dans les instructions : aucun fichier supplémentaire à synchroniser.

  • Open source

    Publiée par skydoves sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Entering Text dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Copiez l’URL ci-dessous, qui pointe vers le dossier de la compétence, puis collez-la et confirmez.
    https://github.com/skydoves/android-testing-skills/tree/main/compose/actions/entering-text
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter une compétence → Via une URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/skydoves/android-testing-skills.git /tmp/android-testing-skills
mkdir -p .claude/skills
cp -r /tmp/android-testing-skills/compose/actions/entering-text .claude/skills/entering-text
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Entering Text dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Entering Text dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, la compétence Entering Text n’est pas liée au modèle pour lequel elle a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

Entering Text — performTextInput, performTextReplacement, performImeAction

Compose text fields expose semantics actions for IME-style edits. The test API wraps those actions so a single call types text, replaces text, clears text, sets a selection, or fires the IME action. Every entry point auto-focuses the node when needed and asserts that the node is enabled and editable, surfacing precise errors when one of those preconditions fails.

When to use this skill

  • The test types into TextField, OutlinedTextField, BasicTextField, or any composable that exposes the InsertTextAtCursor / SetText semantics actions.
  • The test fires an IME action — ImeAction.Next to advance focus, ImeAction.Done to dismiss the keyboard, ImeAction.Search / Send / Go to trigger a form submit.
  • The test must clear an existing value, or replace the full value with new text.
  • The test asserts cursor or selection state with performTextInputSelection(TextRange(...)).

When NOT to use this skill

  • The test sends an arbitrary key shortcut into a focused field (e.g. Ctrl+A, Tab, arrow keys). Use ../injecting-mouse-and-keyboard/SKILL.md.
  • The test only checks the displayed text without typing — assert via ../../assertions/asserting-node-state-and-text/SKILL.md.
  • A finder cannot locate the text field. Verify the matcher first via ../../finders/finding-nodes-by-tag-text-content/SKILL.md.
  • The test asserts state restoration of the typed text after rotation. See ../../setup/configuring-test-dependencies/SKILL.md and StateRestorationTester.

Prerequisites

  • androidx.compose.ui:ui-test-junit4 (or ui-test for runComposeUiTest) configured per ../../setup/configuring-test-dependencies/SKILL.md.
  • The TextField carries Modifier.testTag("…") from production code so the test selects it deterministically.
  • The field is enabled = true. performTextInput calls assert(isEnabled()) before doing anything (TextActions.kt:125).
  • For performImeAction: the field declares both ImeAction != ImeAction.Default (via KeyboardOptions(imeAction = …)) and an OnImeAction handler (via KeyboardActions(...) or default keyboard actions). The action assertion checks both (TextActions.kt:99-100).

Workflow

  1. Type text at the cursor — performTextInput(text) (TextActions.kt:37-41). Internally invokes SemanticsActions.InsertTextAtCursor with AnnotatedString(text). Auto-focuses the node first when it is not focused (getNodeAndFocus — TextActions.kt:119-138). Throws AssertionError("Failed to perform text input.") if the node is not enabled, not focusable, or does not advertise InsertTextAtCursor.
kotlin
rule.onNodeWithTag(Tag).performTextInput("Hello ")
  1. Replace the entire text — performTextReplacement(text) (TextActions.kt:81-84). Invokes SemanticsActions.SetText, which clears existing text and inserts new text. Use this when the field already has a value the test wants to overwrite. MUST NOT be used to "type more characters" — see the WRONG/RIGHT pair below.
kotlin
rule.onNodeWithTag(Tag).performTextReplacement("New value")
  1. Clear the text — performTextClearance() (TextActions.kt:28-30). Sugar for performTextReplacement(""). The field must be focusable + have SetText.
kotlin
rule.onNodeWithTag(Tag).performTextClearance()
  1. Set the selection / cursor — performTextInputSelection(selection: TextRange, relativeToOriginalText: Boolean = true) (TextActions.kt:61-72). Maps to SemanticsActions.SetSelection. When relativeToOriginalText = true, indices refer to the original (untransformed) text; false makes them refer to the post-VisualTransformation text.
kotlin
rule.onNodeWithTag(Tag).performTextInput("Hello World")
rule.onNodeWithTag(Tag).performTextInputSelection(TextRange(0, 5)) // selects "Hello"
  1. Fire the IME action — performImeAction() (TextActions.kt:97-117). Pre-conditions, in order:
    • assert(hasPerformImeAction()) — the field declares OnImeAction.
    • assert(!hasImeAction(ImeAction.Default)) — the action is something other than the default.
    • tryPerformAccessibilityChecks().
    • Auto-focus via getNodeAndFocus(requireEditable = false).
    • Invoke OnImeAction and require it returned true; otherwise throw AssertionError("Failed to perform IME action, handler returned false.").
kotlin
rule.onNodeWithTag(InitialFieldTag).performImeAction()
  1. Pair with assertTextEquals to confirm the expected post-state. The merged-tree default applies to text assertions exactly as to finders — see ../../assertions/asserting-node-state-and-text/SKILL.md.

Patterns

Pattern: Append (performTextInput) vs replace (performTextReplacement)

The most common gotcha — the two APIs look interchangeable but compose differently.

kotlin
// WRONG
rule.onNodeWithTag(Tag).performTextInput("hello")
rule.onNodeWithTag(Tag).performTextInput("world")
rule.onNodeWithTag(Tag).assertTextEquals("world")
// WRONG because: performTextInput maps to InsertTextAtCursor, not SetText. The cursor
// remains at the end of "hello" after the first call, so the second call inserts
// "world" there. Final value is "helloworld" — assertion fails.
kotlin
// RIGHT
rule.onNodeWithTag(Tag).performTextInput("hello")
rule.onNodeWithTag(Tag).performTextReplacement("world")
rule.onNodeWithTag(Tag).assertTextEquals("world")

performTextReplacement calls SemanticsActions.SetText (TextActions.kt:83), which clears existing characters before inserting the new text — equivalent to the IME's "set composing region to whole text and replace" path. Use it any time the second call should overwrite, not append.

Pattern: Canonical insert + assert

From BasicTextFieldTest.kt:171-194:

kotlin
@Test
fun textFieldState_textChange_updatesState() {
    val state = TextFieldState("Hello ", TextRange(Int.MAX_VALUE))
    inputMethodInterceptor.setTextFieldTestContent {
        BasicTextField(state = state, modifier = Modifier.fillMaxSize().testTag(Tag))
    }

    rule.onNodeWithTag(Tag).performTextInput("World!")

    rule.runOnIdle { assertThat(state.text.toString()).isEqualTo("Hello World!") }
}

@Test
fun textFieldState_textChange_updatesSemantics() {
    val state = TextFieldState("Hello ", TextRange(Int.MAX_VALUE))
    inputMethodInterceptor.setTextFieldTestContent {
        BasicTextField(state = state, modifier = Modifier.fillMaxSize().testTag(Tag))
    }

    rule.onNodeWithTag(Tag).performTextInput("World!")

    rule.onNodeWithTag(Tag).assertTextEquals("Hello World!")
}

The cursor is positioned at TextRange(Int.MAX_VALUE) (end of text) when constructing TextFieldState. performTextInput("World!") inserts at that cursor — final value "Hello World!". State reads happen inside runOnIdle (skydoves hot take #5).

Pattern: Replace then assert — BasicTextFieldTest.kt:442-466

kotlin
@Test
fun textField_whenStateObjectChanges_restartsInput() {
    val state1 = TextFieldState("Hello")
    val state2 = TextFieldState("World")
    var toggleState by mutableStateOf(true)
    val state by derivedStateOf { if (toggleState) state1 else state2 }
    inputMethodInterceptor.setTextFieldTestContent {
        BasicTextField(
            state = state,
            enabled = true,
            modifier = Modifier.fillMaxSize().testTag(Tag),
        )
    }

    with(rule.onNodeWithTag(Tag)) {
        performTextReplacement("Compose")
        assertTextEquals("Compose")
    }
    toggleState = !toggleState
    with(rule.onNodeWithTag(Tag)) {
        performTextReplacement("Compose2")
        assertTextEquals("Compose2")
    }
    assertThat(state1.text.toString()).isEqualTo("Compose")
    assertThat(state2.text.toString()).isEqualTo("Compose2")
}

performTextReplacement overwrites whatever the field's current value happens to be — making it the right call when state is rotated underneath.

Pattern: Clearing then refilling

kotlin
rule.onNodeWithTag(Tag).performTextClearance()
rule.onNodeWithTag(Tag).performTextInput("Different")
rule.onNodeWithTag(Tag).assertTextEquals("Different")

performTextClearance is sugar for performTextReplacement("") (TextActions.kt:28-30). After it runs, the cursor is at position 0, so a follow-up performTextInput simply inserts at the start.

Pattern: IME-action focus chain (Next advances focus)

From DefaultKeyboardActionsTest.kt:130-149:

kotlin
// Show keyboard.
rule.onNodeWithTag(initialTextField).performClick()
inputMethodInterceptor.assertSessionActive()
keyboardController.show()

// Act.
rule.onNodeWithTag(initialTextField).performImeAction()

// Assert.
when (imeAction) {
    Next -> {
        // Focus moves to the next item.
        assertThat(focusState1).isFalse()
        assertThat(focusState2).isFalse()
        assertThat(focusState3).isTrue()
    }
    Previous -> {
        // Focus moves to the previous item.
        assertThat(focusState1).isTrue()
        assertThat(focusState2).isFalse()
        assertThat(focusState3).isFalse()
    }
    Done -> {
        // No change to focus state.
        assertThat(focusState1).isFalse()
        assertThat(focusState2).isTrue()
        assertThat(focusState3).isFalse()

        // Software keyboard is hidden.
        keyboardController.assertHidden()
    }
}

Production must declare a non-default ImeAction for performImeAction to be valid:

kotlin
BasicTextField(
    state = state,
    keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
    modifier = Modifier.testTag(InitialFieldTag),
)

performImeAction asserts !hasImeAction(ImeAction.Default) first (TextActions.kt:100). Forgetting the keyboardOptions parameter yields AssertionError("Failed to perform IME action.").

Pattern: Set selection before replacing a substring

kotlin
rule.onNodeWithTag(Tag).performTextInput("Hello World")
rule.onNodeWithTag(Tag).performTextInputSelection(TextRange(6, 11)) // select "World"
rule.onNodeWithTag(Tag).performTextInput("Compose")              // selection replaced
rule.onNodeWithTag(Tag).assertTextEquals("Hello Compose")

SemanticsActions.SetSelection honours the same path the IME uses, so a follow-up InsertTextAtCursor replaces the active selection with the new text. Pass relativeToOriginalText = false if the field installs a VisualTransformation (e.g. password mask, currency formatter) and the indices were computed against the displayed string.

Pattern: Disabled or non-editable field — clear error

If the field is enabled = false or the matcher resolves to a Text instead of a TextField, performTextInput throws AssertionError("Failed to perform text input."). The chain is:

  1. tryPerformAccessibilityChecks().
  2. assert(isEnabled()).
  3. assert(hasRequestFocusAction()).
  4. assert(hasSetTextAction()) and assert(hasInsertTextAtCursorAction()) (TextActions.kt:127-129).

When the assertion fires, dump the semantics tree via ../../debug/printing-the-semantics-tree/SKILL.md to confirm the matcher is not selecting a static Text.

Mandatory rules

  • MUST use performTextReplacement to overwrite an existing value. MUST NOT chain two performTextInput calls expecting the second to replace the first — they concatenate at the cursor.
  • MUST declare a non-default ImeAction (e.g. KeyboardOptions(imeAction = ImeAction.Next)) before calling performImeAction. The API asserts !hasImeAction(ImeAction.Default) (TextActions.kt:100) and throws otherwise.
  • MUST select the field by Modifier.testTag(...) whose value is a constant in production code — skydoves hot take #1.
  • MUST route post-input state assertions through rule.runOnIdle { … } (skydoves hot take #5). The recomposer needs to settle before reading TextFieldState.text.
  • MUST NOT call Thread.sleep to wait for IME events. Compose's idle observation includes the text-input pipeline; the assertion will be ready when runOnIdle returns.
  • MUST NOT simulate text entry by injecting individual Key events through performKeyInput { pressKey(Key.A) } unless the test specifically exercises the hardware-keyboard path. The semantics actions are the canonical IME path.
  • PREFERRED: keep performTextInputSelection calls explicit about relativeToOriginalText. The default (true) is correct for most cases; flip it only when the field installs a VisualTransformation.

Verification

  • Every test that overwrites field content uses performTextReplacement(...) or performTextClearance() followed by performTextInput(...). No back-to-back performTextInput calls expecting replacement semantics.
  • Every performImeAction call targets a field that declares KeyboardOptions(imeAction = ImeAction.Next | Done | Search | …) in production source.
  • State or text assertions following an input action run inside rule.runOnIdle { … }.
  • No Thread.sleep in the test method.
  • ./gradlew :app:connectedDebugAndroidTest (or :app:testDebugUnitTest for Robolectric) passes for the test under change.

References

Foire aux questions

À quoi sert la compétence IA Entering Text ?

Utilisez cette compétence pour piloter les champs de texte Jetpack Compose depuis des tests avec les actions dédiées au texte : performTextInput (insère au niveau du curseur via l’action sémantique InsertTextAtCursor), performTextReplacement (efface puis remplace via SetText), performTextClearance (remplace par une chaîne vide), performTextInputSelection (définit la sélection TextRange) et performImeAction (déclenche l’action IME configurée, comme Next, Done ou Search). Elle couvre le parcours de mise au point automatique, les prérequis enabled / editable / focusable, le piège de l’ajout au...

Pourquoi utiliser Entering Text sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Entering Text se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Entering Text dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/skydoves/android-testing-skills/tree/main/compose/actions/entering-text. TypingMind lit le fichier SKILL.md et l’installe sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Entering Text ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Entering Text ?

Autant que vous le souhaitez. Vous pouvez utiliser Entering Text avec tout modèle qui prend en charge les compétences : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Entering Text est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par skydoves sous licence Apache-2.0. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, gabarits ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace de travail IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇