pedrovgs / Shot

Screenshot testing library for Android
Apache License 2.0
1.18k stars 115 forks source link

Problem: is there a way to capture bottom sheet while its open? #317

Open R-Ashh opened 2 years ago

R-Ashh commented 2 years ago

I am trying to capture a bottom sheet on some scenarios, when I use the compareWith and pass the activityOnTop it won't capture the Bottomsheet and only the Activity itself is there any possibility to achieve this?

@Test
  fun addSomethingToTheInput() {
    val activity = ActivityScenario.launch<AccountsActivity>(
      AccountsActivity.getIntent(context = targetContext)
    )
    activity.waitForActivity()

    assertOnView(
      AccountPage.addAccountButton(),
      ViewAssertions.matches(ViewMatchers.isDisplayed())
    )

    compareScreenshot(activityOnTop)

    AccountPage.apply {
      openBottomSheetDialog()
      selectFirstItemFromDialog()
      selectEnterAccountNumberInput()
      typeAccountNumberIntoTheInput()
      closeSoftKeyboard()
      compareScreenshot(activityOnTop, name = "add Account number")
      clickSaveButton()
    }

    compareScreenshot(activityOnTop)
  }

with this code all I get is the activity in the background even tho the Bottomsheet is open on the screen and I can see it in action in the emulator.