Android, Robotium - Issue taking screenshot

北城以北 提交于 2019-12-01 11:44:14

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.

user952342

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:\

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!