-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable taking screenshots from dialogs #176
Comments
@jdeebee Testify does not capture dialogs by default due to the way that Testify only captures a bitmap from the current Window. As Dialogs are rendered as separate windows, they require a use of a different capture method. Fortunately, Testify does support capturing the entire screen, including Dialogs, through the user of the FullscreenCapture method. To capture dialogs with Testify:
For more information, see the example here. |
@DanielJette Great to hear this is already possible. Will try it today. Thanks for your quick answer! |
@DanielJette I tried your suggested approach, however no system UI exclusion method is found in These are the versions I tried: androidTestImplementation "dev.testify:testify-fullscreen:2.0.0-beta04"
androidTestImplementation "dev.testify:testify-fullscreen:2.0.0-beta02" I use the same version for the gradle plugin classpath as well (so that they can be matched correctly): classpath "dev.testify:plugin:2.0.0-beta04"
classpath "dev.testify:plugin:2.0.0-beta02" And this is how I configure the test rule: ScreenshotRule(activityClass)
.configure { exactness = 0.94f }
.setCaptureMethod(::fullscreenCapture)
.excludeStatusBar()
.withExperimentalFeatureEnabled(TestifyFeatures.GenerateDiffs) |
@jdeebee It does look like the documentation was not correctly updated for beta04 In the meantime, you can use the import dev.testify.capture.fullscreen.provider.excludeStatusBar
@get:Rule val rule = ScreenshotRule(MainActivity::class.java)
rule
.configure {
exactness = 0.94f
captureMethod = ::fullscreenCapture
excludeStatusBar()
}
.withExperimentalFeatureEnabled(TestifyFeatures.GenerateDiffs)
.assertSame() |
Is your feature request related to a problem? Please describe.
I was surprised to find out that Testify cannot verify/take a screenshot of dialogs. I believe this should be a core functionality of a snapshot testing library as dialogs are used in many apps and SDKs. I came across this old issue from another library and this Testify issue and now I understand why it's currently not possible, but it would be lovely if you could add a mechanism to take and verify a screenshot of a provided
Window
orView
outside the activity view hierarchy.This feedback relates to:
Describe the solution you'd like
Introduce a way to take and verify a screenshot of a provided
Window
orView
outside the activity view hierarchyDescribe alternatives you've considered
(Potentially) introduce an Espresso/AndroidX test rule for dialogs specifically
Additional context
N/A
The text was updated successfully, but these errors were encountered: