CmdWindow Methods

ClearScreen

Clears the current console session by running the "cls" command.

Syntax:

public void ClearScreen()

EnterText

Enters the specified text in the console and verifies the input.

Syntax:

public void EnterText(
	string textToEnter
)

Parameters:

MakeReadyForNewCommand

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.

Syntax:

public bool MakeReadyForNewCommand(
	bool throwException = true
)

Parameters:

Return Value:

True if console is ready for a new command, false or exception otherwise.

Exceptions:

RunCommand

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

Syntax:

public void RunCommand(
	string command,
	int timeoutInSeconds = 60
)

Parameters:

Exceptions:

VerifyText

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.

Syntax:

public bool VerifyText(
	params string[] expectedTextWithVariants,
	out string lastCmd
)

Parameters:

Return Value:

Returns true if one of the text variants appears in the output of the last command or the command itself.

WaitForCmdToComplete

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.

Syntax:

public bool WaitForCmdToComplete(
	int timeout = 60,
	bool throwException = true
)

Parameters:

Return Value:

True if command is completed within the specified timeout, false or exception otherwise.

Exceptions:

Last updated