Compose Layout Blocking Access?

Hello, everybody! I have a problem accessing some elements of our native Jetpack Compose-based app.

Think of a page where you can toggle some switches. Next to those switches there are two TextViews which describe what happens after you activate the switch. Our team decided it would be better, if you can toggle the switches by tapping the TextViews, too. So devs stacked a transparent Box just on top of the switch and the TextViews. The problem: I cannot access the switches and check their state via their attributes. Is the layout construction itself blocking access?

Take a look at our production code:

@Composable
internal fun CustomTextSwitchItem(
    switchToggledState: Boolean,
    onClickToggleSwitchState: () -> Unit,
    modifier: Modifier = Modifier,
    switchEnabledState: Boolean = true,
) {
    Box(
        contentAlignment = Alignment.Center,
        modifier = Modifier
            .fillMaxWidth()
            .clickable { onClickToggleSwitchState() }
    ) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceBetween,
            modifier = modifier
        ) {
            Column(Modifier.weight(1f)) {
                Text(text = "Headline")
                Text(text = "SubHeadline")
            }
            Switch(
                checked = switchToggledState,
                enabled = switchEnabledState,
                onCheckedChange = null
            )
        }
    }
}

@Preview(widthDp = 480)
@Composable
fun CustomPreview() {
    CustomTextSwitchItem(
        switchToggledState = false,
        onClickToggleSwitchState = {},
        modifier = Modifier,
        switchEnabledState = true
    )
}

Hi @severin.heidrich.

Generally TestProject can detect anything that appium does, what are you using to locate elements currently?

This topic was automatically closed after 180 days. New replies are no longer allowed.