openNotification

suspend fun openNotification(title: String? = null, text: String? = null, mode: MatchMode = MatchMode.EXACT, packageName: String? = null, action: String? = null, timeout: Duration? = null)(source)

Opens the one active notification that matches (as for awaitNotification) as a tap on it in the shade does: sends its content intent and, when it auto-cancels, removes it. With action, presses its action button with exactly that title instead, and the notification stays. No match or several matches throw CommandException (NOT_FOUND / AMBIGUOUS), and a notification that opens nothing or has no such action ACTION_REJECTED (ACTION_NOT_OFFERED), before anything is sent. What the app does then is for the test to assert (an activity, say: foregroundActivity).