android-uiautomatoruiautomatorviewer

Uiautomator - takeScreenshot -is there a way to take screenshots for different UI object


In a uiautomator test, is there a way to take screenshots for different UI object. For example, there are two UI elements (one is view class, one is scroll View class), how can I take screen shots for these two UI elements separately?

Using takeScreenshot() only takes screen shots for the whole screen view.

Thanks!


Solution

  • You can use AndroidViewClient/culebra to take snapshots of particular Views.

    Using Culebra GUI you can just just use the context menu and then Take View snapshot and save to file.

    A line similar to this will be generated in the test or script

    android___id_widget_frame.writeImageToFile('/tmp/${serialno}-android___id_widget_frame-${timestamp}.png', 'PNG')
    

    which you can adapt to your needs. Then, every time you run the test or script you will have a new snapshot taken.