Android, Robotium - Issue taking screenshot

后端 未结 3 1261
感动是毒
感动是毒 2021-01-15 16:40

I\'m trying to take a screenshot of my Android application using Robotium, I\'m using the below function that I found here.

public static String SCREEN_SHOTS         


        
相关标签:
3条回答
  • 2021-01-15 17:11

    For taking screen shot at any point of the application Just write this piece of code

    solo.takeScreenshot();

    But don't forget to give permission in your main Application.

    0 讨论(0)
  • 2021-01-15 17:21

    Make sure your emulator has some megabytes set aside for the SD card.

    If you want to pull the jpg back to your PC, you can get java to run this command line:

    C:\Users\Me\android-sdks\platform-tools\adb.exe pull /sdcard/test_1329402481933.jpg c:\

    0 讨论(0)
  • 2021-01-15 17:30

    The reason why you are getting NullPointerException is because you are using getView(int id) incorrectly. As you are giving it an index instead of id, it will not find the view that you are looking for and thus returns null. What you want to use is following:

    takeScreenShot(solo.getViews().get(0), "Test")

    Which means the first view of all the views available to Robotium at a given time.

    0 讨论(0)
提交回复
热议问题