execute command
Name | Description | Type | Modifier |
---|---|---|---|
command | Command to be executed | String | None |
variable | Variable to receive the command output. | String | None |
timeout | Maximum wait time for the specified command to complete execution. If the timeout is reached, the running command is terminated (units: seconds). Default Value: 300 | String | None |
charset | Charset: (Optional) The encoding type of execute command’s output. | Value Set | SHIFT-JIS,UTF-8 |
Example - Case 1
Suppose you issue the dir command in your automation script to see the available files and directories in the
D:\Development directory.
Action lines
command variable time out charset
execute command dir D:\Development var_output 400 UTF-8
Result
Instead of writing the dir output to the var_output variable, you can write the output to a file by using the redirect command output (>) operator.
Action lines
command variable time out charset
execute command dir D:\Development>D:\log.txt var_output 400 UTF-8
Result
Effect
Example - Case 2
Suppose you may want to issue two commands in your automation script.
- One command is to launch an application, such as Internet Explorer, and
- the other is to see available files in a specified directory, such as D:\Development.
Additionally, these two commands must run asynchronously (without waiting for each command to finish).
command variable time out charset
execute command start "title" "C:\Program File (x86)\Internet Explore.exe" var_output_ie 30 UTF-8
execute command dir D:\Development var_output_dir 30 UTF-8
Result
This built-in action is supported only on Windows test controllers, it is effective on Windows test platforms.
The execute command action can be invoked to execute any of the following:
- Command line utilities.
- Any application that can be invoked from the command line.
execute command works synchronously: that is, it causes test execution to wait for the specified command to finish before control is returned to the test. To execute commands asynchronously – that is, launch a command or application and continue with the test run without waiting – precede the contents of your command with the start command (see Example - Case 2).
Tip:You can view the full syntax of the start command by typing start /? in the command prompt window.If you want to write the command output to a file, rather than to the variable defined in the variable argument, use the redirect command output (>) operator in your command string. For example, to redirect a directory listing to the file dirlist.txt:
Action lines
command variable execute command dir > dirlist.txt x
(Note that the output is fully directed to the file, and that the variable, while still a required argument, remains empty, or at its previous value.)
- This action supports the <ignore> modifier. If the string
<ignore>
is present as the value of any of the arguments, or any argument contains an expression that evaluates to<ignore>
, the action is skipped during execution.