diff --git a/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt b/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt index 90be6d6f41..a154d8b361 100644 --- a/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt +++ b/maestro-orchestra-models/src/main/java/maestro/orchestra/Commands.kt @@ -573,7 +573,7 @@ data class EraseTextCommand( data class TakeScreenshotCommand( val path: String, - val cropOn: ElementSelector?, + val cropOn: ElementSelector? = null, override val label: String? = null, override val optional: Boolean = false, ) : Command { diff --git a/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt b/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt index 3339c9a316..31ce8398bf 100644 --- a/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt +++ b/maestro-orchestra/src/test/java/maestro/orchestra/MaestroCommandSerializationTest.kt @@ -428,7 +428,7 @@ internal class MaestroCommandSerializationTest { fun `serialize TakeScreenshotCommand`() { // given val command = MaestroCommand( - TakeScreenshotCommand("screenshot.png") + TakeScreenshotCommand("screenshot.png", cropOn = ElementSelector(textRegex = "[A-f0-9]")) ) // when @@ -441,6 +441,10 @@ internal class MaestroCommandSerializationTest { { "takeScreenshotCommand" : { "path" : "screenshot.png", + "cropOn" : { + "textRegex" : "[A-f0-9]", + "optional" : false + }, "optional" : false } } diff --git a/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt b/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt index f5bcdcb5bc..a39c750335 100644 --- a/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt +++ b/maestro-test/src/test/kotlin/maestro/test/IntegrationTest.kt @@ -3174,7 +3174,7 @@ class IntegrationTest { @Test fun `Case 119 - Take cropped screenshot`() { // Given - val commands = readCommands("118_take_cropped_screenshot") + val commands = readCommands("119_take_cropped_screenshot") val boundHeight = 100 val boundWidth = 100 @@ -3200,7 +3200,7 @@ class IntegrationTest { Event.TakeScreenshot, ) ) - val file = File("118_take_cropped_screenshot_with_filename.png") + val file = File("119_take_cropped_screenshot_with_filename.png") val image = ImageIO.read(file) assert(file.exists())