File tree 2 files changed +19
-6
lines changed
maestro-orchestra/src/main/java/maestro/orchestra
maestro-orchestra-models/src/main/java/maestro/orchestra
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,8 @@ data class TapOnElementCommand(
265
265
) : Command {
266
266
267
267
override fun description (): String {
268
- return label ? : " ${tapOnDescription(longPress, repeat)} on ${selector.description()} "
268
+ val optional = if (optional) " (Optional) " else " "
269
+ return label ? : " ${tapOnDescription(longPress, repeat)} on $optional${selector.description()} "
269
270
}
270
271
271
272
override fun evaluateScripts (jsEngine : JsEngine ): TapOnElementCommand {
@@ -379,7 +380,8 @@ data class AssertConditionCommand(
379
380
}
380
381
381
382
override fun description (): String {
382
- return label ? : " Assert that ${condition.description()} "
383
+ val optional = if (optional) " (Optional) " else " "
384
+ return label ? : " Assert that $optional${condition.description()} "
383
385
}
384
386
385
387
override fun evaluateScripts (jsEngine : JsEngine ): Command {
Original file line number Diff line number Diff line change @@ -678,10 +678,21 @@ class Orchestra(
678
678
updateMetadata(command, metadata)
679
679
680
680
return @mapIndexed try {
681
- executeCommand(evaluatedCommand, config)
682
- .also {
683
- onCommandComplete(index, command)
684
- }
681
+ try {
682
+ executeCommand(evaluatedCommand, config)
683
+ .also {
684
+ onCommandComplete(index, command)
685
+ }
686
+ } catch (exception: MaestroException ) {
687
+ val isOptional = command.asCommand()?.optional == true
688
+ if (isOptional) throw CommandWarned (exception.message)
689
+ else throw exception
690
+ }
691
+ } catch (ignored: CommandWarned ) {
692
+ // Swallow exception, but add a warning as an insight
693
+ Insights .report(Insight (message = ignored.message, level = Insight .Level .WARNING ))
694
+ onCommandWarned(index, command)
695
+ false
685
696
} catch (ignored: CommandSkipped ) {
686
697
// Swallow exception
687
698
onCommandSkipped(index, command)
You can’t perform that action at this time.
0 commit comments