DeviceCapture.takeScreenshot() timeout issue
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- android, kotlin
- Domain
- mobile-dev, testing
Research direction
Start by reading the current DeviceCapture.takeScreenshot() and forceRedrawGlobalWindowViews() implementation, then compare it with the core v1.5.0 implementation. Reproduce the failure with an Espresso TestWatcher and inspect why a non-shown view blocks the redraw; done means failed tests capture and write a screenshot on Android OS versions 31–33 without timing out.
Written by the indexing model from the issue text.
Description
Description
Calling DeviceCapture.takeScreenshot() in a test rule on test failure times out and takes no screenshot
Steps to Reproduce
- Create any kind of Espresso JUnit test
- Create a test rule extending
TestWatcher()and try to take a screenshot on failure and write it to test storage.
Expected Results
Screenshot should be taken and saved in the test storage
Actual Results
No screenshot is taken, calling takeScreenshot() times out.
AndroidX Test and Android OS Versions
androidx.test.core v1.6.1
androidx.test.espresso:espresso* v3.6.1
OS: Tested on emulators with OS versions 31-33
Additional debug information
I am just a QA engineer so I can't speak about the app implementation but what I found is that forceRedrawGlobalWindowViews() finds 2 views in the context of our app. For one of the views view.isShown returns false and the redraw seems to fail on this particular one. I copied the DeviceCapture implementation and added a condition to redraw only views that are "shown" and screenshots started working.
NB The issue cannot be observed on core v1.5.0 and espresso libraries v3.5.1 but there the DeviceCapture implementation is completely different than the latest one.
Link to a public git repo demonstrating the problem:
Example test rule used
class ScreenshotTestRule : TestWatcher() {
override fun failed(e: Throwable?, description: Description?) {
super.failed(e, description)
val className = description?.testClass?.simpleName ?: "NullClassname"
val methodName = description?.methodName ?: "NullMethodName"
takeScreenshot().writeToTestStorage("${className}_${methodName}")
}}
Rule added to test class
@get:Rule(order = 1)
var screenshotWatcher = ScreenshotTestRule()
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 342
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from android/android-test
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
android/android-test#681 · 2 comments · 1 reaction ·
-
ξεκσνδξδ Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
android/android-test#2499 ·
-
ησξξσ Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
android/android-test#2498 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
android/android-test#2473 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
android/android-test#2461 · 6 comments · 4 reactions ·
All issues in android/android-test
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
area/frontend
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100