CmdWindow Methods
Clears the current console session by running the "cls" command.
public void ClearScreen()
Enters the specified text in the console and verifies the input.
public void EnterText(
string textToEnter
)
Parameter | Description |
textToEnter |
Makes sure the console is ready for a new command. Clears existing input text that is not run yet and aborts a running command with Ctrl+C if necessary.
public bool MakeReadyForNewCommand(
bool throwException = true
)
Parameter | Description |
[throwException] | Type: Boolean
If set to true throws an exception if console is not ready for a new command, otherwise returns false. |
True if console is ready for a new command, false or exception otherwise.
Exception | Condition |
Command window was not ready for a new command |
Enters the provided command and runs it by pressing enter. Returns as soon as the first output of the command is received (on the next line) or the command completes. If your command logs output to the console you probably want to follow RunCommand with WaitForCmdToComplete
Example to run you own command from a test case:
var cmd = App.SystemHelpers.OpenCommandLineWindow();
cmd.RunCommand("my command");
cmd.WaitForCmdToComplete(); // not required if my command doesn't log
public void RunCommand(
string command,
int timeoutInSeconds = 60
)
Exception | Condition |
Command did not complete within timeoutInSeconds. |
Verifies the expected text appears in the output of the last command.
Allows to pass in different variants of the text in order to allow for different localisations.
public bool VerifyText(
params string[] expectedTextWithVariants,
out string lastCmd
)
Parameter | Description |
expectedTextWithVariants | Type: String[ ]
The text to verify in the console. Can be multiple strings that are e.g. different localisations, which are all accepted. Array must not be empty. |
[lastCmd] | Type: String
Returns the full output of the last command, to enable further checks without the need to get the text again. |
Returns true if one of the text variants appears in the output of the last command or the command itself.
Waits for a command to complete by waiting until the console is ready for a new command.
Note: an input request is not considered a completed command and will mostly likely timeout the method.
public bool WaitForCmdToComplete(
int timeout = 60,
bool throwException = true
)
True if command is completed within the specified timeout, false or exception otherwise.
Exception | Condition |
Command did not complete within timeoutInSeconds and throwException is true. |
Last modified 7mo ago