Right now all classes and methods from androidx.test.runner.screenshot are deprecated. Current solution require usage of the new api from androidx.test.espresso.screenshot and saving files with androidx.test.services.storage.TestStorage which resolve some issues with external storage on API 32+:
onView(isRoot())
.captureToBitmap()
.writeToTestStorage(screenshotName)
Using this method unfortunately show error on dashboard (probably screenshoot cannot be extracted from the device):

Edit
Currently only working solution for Android Q and above is to use ContentProvider for storing screenshots in downloads