mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.91k stars 281 forks source link

Unable to tapOn specific text in Jetpack Compose AnnotatedString #389

Open adityahas opened 2 years ago

adityahas commented 2 years ago

Clickable string on Jetpack Compose annotated text view apparently not recognized as clickable items by Maestro. Causing tapOn unable to execute click on desired annotated texts.

sdf
appId: mba.lumina.dev
---
- launchApp
- tapOn: "Mulai cari loker"
- tapOn: "Masuk"
- tapOn: "Syarat & Ketentuan"

Compose code

ClickableText(
        text = annotatedString,
        color = LuminaColor.Grey4,
        textAlign = TextAlign.Center,
        style = LuminaTheme.typography.subtitle
    ) { offset ->
        annotatedString.getStringAnnotations(tag = "terms", start = offset, end = offset)
            .firstOrNull()?.let { stringAnnotation ->
                handleEvent(
                    PrivacyPolicyEvent.ShowWebView(
                        "Syarat & Ketentuan",
                        stringAnnotation.item
                    )
                )
            }
        annotatedString.getStringAnnotations(tag = "policy", start = offset, end = offset)
            .firstOrNull()?.let { stringAnnotation ->
                handleEvent(
                    PrivacyPolicyEvent.ShowWebView(
                        "Kebijakan Privasi",
                        stringAnnotation.item
                    )
                )
            }
    }

Any idea?

likeSo commented 2 years ago

This command fails on "NSAttributedString" also. It looks like the rich texts does not support yet