Commands
if
Conditionally execute commands based on a specified condition.
Description
The if
command is used to conditionally execute a set of commands based on whether a specified condition evaluates to true or false. If the condition is true, the commands in the then
block are executed. Otherwise, the commands in the else
block are executed.
Arguments
Argument | Type | Description |
---|---|---|
condition | string | The condition to evaluate. |
then | list of commands | The commands to run if the condition is true. |
else | list of commands | The commands to run if the condition is false. |
Example usage
Protips
- Ensure the
condition
is clearly defined and evaluates correctly to avoid unexpected behavior. - Use descriptive
then
andelse
blocks to handle both outcomes effectively. - Combine the
if
command with other commands likehover-text
orfocus-application
to create dynamic workflows.
Gotchas
- If the
condition
is invalid or can’t be evaluated, the command will fail. - Ensure all commands in the
then
andelse
blocks are valid and properly formatted.
Notes
- The
if
command is useful for creating conditional logic in your tests, allowing for more dynamic and flexible workflows. - Both the
then
andelse
blocks are optional, but at least one must be provided.