pedrovgs / Shot

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

Not able to generate screenshots #281

Closed ndeka28 closed 2 years ago

ndeka28 commented 2 years ago

Expected behaviour

When I run ./gradlew executeScreenshotTests -Precord , screenshots should be generated

Actual behaviour

I am using Shot version 5.13.0, while trying to run the above command I am getting error

> Task :app:connectedDebugAndroidTest
Starting 1 tests on Nexus_5X_API_27(AVD) - 8.1.0

> Task :app:debugDownloadScreenshots
⬇️  Pulling screenshots from your connected devices!
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/com.nila.testshot.test/screenshots-default/
Shot ADB warning: We could not pull screenshots from folder: /storage/emulated/0/Download/screenshots/com.nila.testshot.test/screenshots-compose-default/
Shot ADB warning: rm: /storage/emulated/0/Download/screenshots/com.nila.testshot.test/screenshots-compose-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/Karumi/Shot/#getting-started

Steps to reproduce

  1. Created an new Android Project
  2. Added plugin and test runner testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
  3. Added manifest file in AndroidTest folder
    
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nila.testshot.test"
    android:sharedUserId="com.nila.testshot.uid">


4. Added Test code

package com.nila.testshot.test

import androidx.test.core.app.ActivityScenario import com.karumi.shot.ActivityScenarioUtils.waitForActivity import com.karumi.shot.ScreenshotTest import com.nila.testshot.MainActivity import org.junit.Test

class ExampleInstrumentedTest : ScreenshotTest{ @Test fun openActivityTest() {

    val activity1 = ActivityScenario.launch(MainActivity::class.java).waitForActivity()

    compareScreenshot(activity = activity1)
}

}



### Version of the library
5.13.0

Please help, I am pretty new to this
ndeka28 commented 2 years ago

I did solve the problem. It is about where I create the project in a mac machine.

SachinKasaraddi commented 2 years ago

Where is it recommended to create project in mac machine?

ndeka28 commented 2 years ago

Either $user folder/Documents/Downloads/Desktop - I tried these, and it worked

SachinKasaraddi commented 2 years ago

It worked 🎉