File tree Expand file tree Collapse file tree
app/src/androidTest/java/com/example/reply/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,8 +21,21 @@ import androidx.compose.ui.test.SemanticsNodeInteraction
2121import androidx.compose.ui.test.junit4.AndroidComposeTestRule
2222import androidx.compose.ui.test.onNodeWithContentDescription
2323import androidx.compose.ui.test.onNodeWithTag
24+ import androidx.compose.ui.test.onNodeWithText
2425import androidx.test.ext.junit.rules.ActivityScenarioRule
2526
27+ /* *
28+ * Finds a semantics node with the given string resource id.
29+ *
30+ * The [onNodeWithText] finder provided by compose ui test API, doesn't support usage of
31+ * string resource id to find the semantics node. This extension function accesses string resource
32+ * using underlying activity property and passes it to [onNodeWithText] function as argument and
33+ * returns the [SemanticsNodeInteraction] object.
34+ */
35+ fun <A : ComponentActivity > AndroidComposeTestRule <ActivityScenarioRule <A >, A>.onNodeWithStringId (
36+ @StringRes id : Int
37+ ): SemanticsNodeInteraction = onNodeWithText(activity.getString(id))
38+
2639/* *
2740 * Finds a semantics node from the content description with the given string resource id.
2841 *
You can’t perform that action at this time.
0 commit comments