Open AbdelrahmanTalat opened 1 year ago
We had this problem as well.
Solved by finding the view that we wanted and taking the screenshot of the view within the bottomsheet.
onView(withId(R.id.xxx)).check { view, _ ->
compareScreenshot(view)
}
I'm facing the same issue, but on ModalBottomSheet
from Material M3 library... any news about this?
I'm facing the same issue, but on
ModalBottomSheet
from Material M3 library... any news about this?
My solution is
fun SemanticsNodeInteraction.rootView() = (fetchSemanticsNodes().root as ViewRootForTest).view
rule.setContent {
ModalBottomSheet(
modifier = Modifier.testTag("dialog"),
...
)
}
val view = rule.onNodeWithTag("dialog").rootView()
compareScreenshot(view)
rootView
is for the test to capture the bottomSheet with a transparent background.
If do compareScreenshot(rule.onNodeWithTag("dialog"))
, it will capture the status bar
Expected behaviour
When a snapshot is captured the BottomSheetDialog should be present
Actual behaviour
BottomSheetDialog is not present in a captured snapshot
Steps to reproduce
Create an activity with a BottomSheetDialog when the bottom sheet is displayed and compareScreenshot(activity) is called the resulting snapshot doesn't contain the BottomSheetDialog
Version of the library