maestro icon indicating copy to clipboard operation
maestro copied to clipboard

feat: add `cropOn` screenshots capability

Open TheKohan opened this issue 1 year ago • 6 comments

Proposed changes

This PR extends current capabilities of takeScreenshot command with cropOn prop which is of an ElementSelector type.

Motivation

Visual regression testing is something that has been on the horizon for some time #1222. This PR is aiming to fill the gaps and prepare the ground for further development in this area (will fit #2078 great). Component level screenshots are something that will greatly decrease screenshot size and make component-level tests possible.

Example usage

test-screenshot.yml

appId: com.example.app
---
- launchApp
- tapOn: Playground
- takeScreenshot:
    path: 'Playground'
 ║                                                             
 ║  > Flow: test-flow                                          
 ║                                                             
 ║    ✅   Launch app "com.exapmle.com"                                                        
 ║    ✅   Tap on "Playground"                         
 ║    ✅   Take screenshot Playground                          
 ║            

test-component-screenshot.yml

appId: com.example.app
---
- launchApp
- tapOn: Playground
- takeScreenshot: 
      path: "Markdown"
      cropOn:
        id: MarkdownInput_Example
 ║                                                             
 ║  > Flow: test-flow                                          
 ║                                                             
 ║    ✅   Launch app "com.exapmle.com"      
 ║    ✅   Tap on "Playground"
 ║    ✅   Take screenshot Markdown, cropped id: MarkdownInput_Example
Playground Markdown
image image

Testing

  • would gladly accept any ideas of how to test it with confidence

TheKohan avatar Oct 09 '24 12:10 TheKohan