Skip to content
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

Failing to record screenshots #334

Open
tripolkaandrey opened this issue Feb 13, 2023 · 8 comments
Open

Failing to record screenshots #334

tripolkaandrey opened this issue Feb 13, 2023 · 8 comments

Comments

@tripolkaandrey
Copy link

tripolkaandrey commented Feb 13, 2023

Preface

I am integrating screenshot testing in my Jetpack Compose application. Despite trying different library versions(5.+) and API levels(26-33), I always have some issues. I decided to pick one "combination" and, therefore, issue in the hope of getting some help—and hopefully, insight into issues with other configurations.

Dependencies

Shot => 5.14.1
Jetpack Compose => 1.3.1
Android Gradle Plugin => 7.3.1

Configuration

// `shot-configuration.gradle.kts`

plugins {
    id("com.android.application")
    id("shot")
}

shot {
    tolerance = 1.0 // 1%
}

dependencies {
    androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.3.1")
    debugImplementation("androidx.compose.ui:ui-test-manifest:1.3.1")
}

android {
    defaultConfig {
        testInstrumentationRunner = "com.karumi.shot.ShotTestRunner"
    }
}

Sample

class SampleTest : ScreenshotTest {

    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun test() {
        composeRule.setContent {
            Card {
                Text("I am a sample test.")
            }
        }
        compareScreenshot(composeRule)
    }
}

Device

I am launching an emulator with Pixel 6 API 30 via Android Studio.

Command

./gradlew executeScreenshotTests -Precord

Output

> Task :app:debugDownloadScreenshots
⬇️  Pulling screenshots from your connected devices!
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/app.test/screenshots-default/
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/app.test/screenshots-compose-default/
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/app.test/screenshots-default/: No such file or directory

> Task :app:debugExecuteScreenshotTests
💾  Saving screenshots.
🤔 We couldn't find any screenshot. Did you configure Shot properly and added your tests to your project? https://github.com/pedrovgs/Shot/#getting-started

Behaviour

The emulator seems to be doing the work while running the command. However, afterwards, there are no screenshots on the device and in the local screenshots directory.

@sergio-sastre
Copy link

sergio-sastre commented Feb 16, 2023

@tripolkaandrey
For API 28-33 you need to enable non-SDK interfaces on your emulator via adb:
https://github.com/pedrovgs/Shot#using-shot-on-api-28

are you doing that?

@tripolkaandrey
Copy link
Author

@sergio-sastre Thank you for your suggestion. Yes, I did enable it.

@sergio-sastre
Copy link

@tripolkaandrey
Do you have a windows machine?
Someone reportes similar error to me in this repo:
sergio-sastre/Android-screenshot-testing-playground#20

However, I do run it without any issues.
Could you check out if you also get the same error?

@tripolkaandrey
Copy link
Author

@sergio-sastre

Do you have a windows machine?

No, I am using macOS.

@lucas-livefront
Copy link

I am experiencing the same issue.

@Venkat-juju
Copy link

Same issue... but in my another project it is working fine... Actually for the first time it worked when recording... Then it is not working.. I'm not sure why

@HardSea
Copy link

HardSea commented Jun 2, 2023

After few hours of debugging, I found the problem...

The reason is that there are spaces in the project folder name or in the project path. Removing the spaces moved the screenshots to the project folder and fixed the error:
🤔 We couldn't find any screenshot. Did you configure Shot properly and added your tests to your project? https://github.com/pedrovgs/Shot/#getting-started

@pedrovgs Please, fix the problem or describe it in the documentation

@Venkat-juju
Copy link

My build was having minify enabled in the debug build and when i run screenshot tests for the debug build.. the screenshots were not pulled... after disabling minify, it is working find

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants