Basic Windows Operations

The folder TBox Automation Tools->Basic Windows Operations in the Standard subset contains the following Modules:

TBox Take Screenshot

This Module takes a screenshot of the currently active screen. After you've run your tests, you can view the screenshot in the Detail column of the ExecutionEntry.

The Module TBox Take Screenshot has the following ModuleAttributes:

ModuleAttribute

Description

Environment

Defines whether you want to take a screenshot of your desktop, mobile device, or browser.

If you leave the value empty, Tosca takes a screenshot of the desktop.

Storage Location Type

Optionally, specify whether you want to save your screenshot to Tricentis File Service, a local Directory, or both.

If you don't specify a Storage Location Type, Tosca uses the storage path defined in the setting Screenshot directory.

Directory

Optionally, specify a local path to save the screenshot to.

If you don't specify a Storage Location Type or Directory, Tosca uses the storage path defined in the setting Screenshot directory.

Filename

File name of the screenshot.

This name doesn't include the file extension. You can define the file format in the setting Screenshot image format.

Select Screen

Optionally, specify which screen or application you want to capture. You can choose from the following options:

  • Active Monitor: Capture the screen which currently has an active application.

  • Active Window: Capture the currently active application window.

  • Everything: Capture all currently connected screens.

  • An integer <n>: Capture a specific screen, identified by its index. For example, to capture the second screen connected to your machine, enter 2.

If you don't specify a value, Tricentis Tosca takes a screenshot of all connected screens.

In this example, you perform the following actions:

  • Take a screenshot of your desktop, specifically screen number two.

  • Save it to the local directory C:\MyScreenshots.

  • Name the screenshot monitor_two.

Take a screenshot of the desktop with the Module TBox Take Screenshot

TBox Clipboard

This Module allows you to copy a text to the Microsoft Windows clipboard. You can also use it to verify the text that's in your clipboard, save that text to a buffer, or wait until a certain text is in the clipboard.

It has the following ModuleAttribute:

ModuleAttribute

Description

Value

Value that you want to copy to the clipboard, verify, buffer, or wait on.

Depending on the desired action, use ActionMode Input, Verify, Buffer, or WaitOn respectively.

This example shows how to work with TBox Clipboard.

  • The first TestStep copies the value Sample text to the clipboard.

  • The second TestStep verifies whether the value in your clipboard is Sample text.

TBox Clipboard

TBox Dialog

The Module TBox Dialog steers dialog windows.

  • Microsoft Windows® dialogs: you can steer them without scanning them.

  • Customized dialogs: you need to scan them first.

The Module TBox Dialog has the following ModuleAttributes:

ModuleAttribute

Description

Caption

Caption of the dialog window that you want to steer. This caption identifies the dialog window.

Label

You can enter the text of the dialog window’s first paragraph for further identification. It's not necessary to enter the entire text.

This ModuleAttribute is optional.

Button

Specify which button Tosca should click to confirm the dialog. Enter the text of the button.

This example shows how to steer the following dialog:

Dialog you want to steer

The TestStep performs the following actions:

  • Identifies the Example: TBox Dialog dialog

  • Uses the text from the dialog window for further identification

  • Clicks the OK button

TBox Dialog example

TBox Context Menu

The Module TBox Context Menu allows you to control context menus of applications based on .NET and WinForms (DotNet Engine 3.0) and the Microsoft UI Automation framework (UIA Engine 3.0).

To use the Module TBox Context Menu, the context menu that you want to steer has to be open so Tricentis Tosca can detect it.

It has the following ModuleAttributes:

ModuleAttribute

Description

Menu

Path to the menu item.

Specify the context menu path with ->, for instance Insert->Image.

Menu-><MenuItem>

Alternatively, you can use this ModuleAttribute to steer a context menu with control hierarchy instead (see example below).

In the example below, you perform the following actions:

  • TestStep Open context menu right-clicks the area of the control My folders to open the context menu.

  • TestStep TBox Context Menu selects the entry New -> Folder from the previously opened context menu.

Steer a context menu example

In this example, you select the entry Insert->New Image of a context menu which is currently open.

It does so in two different ways:

  • In TestStep TBox Context Menu - Control Hierarchy, you steer the context menu via control hierarchy to select the entry New Image.

  • In TestStep TBox Context Menu - Inline Syntax, you steer the context menu via inline syntax to select the entry New Image.

Different ways to steer a WinForms context menu

TBox Send Keys

This Module sends keyboard commands to a window. Like the SendKeys keyboard command, the Module TBox Send Keys uses the WinForms function SendKeys.

The Module TBox Send Keys has the following ModuleAttributes:

ModuleAttribute

Description

Caption

Optionally, enter the caption assigned to the window you want to steer. Tosca brings the window to the foreground.

You can add either a leading or trailing wildcard, i.e. a wildcard at the start or at the end of a string.

Keys

Keyboard command that you want to send to the window.

By default, the DataType is RawString. Tosca sends RawString data exactly as entered to the system under test. No need to escape special characters.

Tosca uses the WinForms function SendKeys. For a list of available SendKeys commands and their syntax, see the Microsoft SendKeys documentation: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx.

If you activate CAPS LOCK on your machine, Tosca sends the keys inverted. For example, if you want to send Abc and have CAPS LOCK on, Tricentis Tosca sends aBC.

By default, F6 is the key to cancel test runs. So, if you want to send F6 to your application as part of a test case, you must first change the default cancel key in the Tosca settings. Otherwise, Tosca cancels the test run when it gets to the test step that sends F6.

To use dynamic expressions in your keyboard commands, select the DataType String

In this example, you send a value and several keyboard commands to the file Example_Send_Key.txt.

Use the DataType RawString for all Keys ModuleAttributes.

Key combination

TestStepValue

Description

Text

This is an example text.

Input text.

Ctrl + A

^(a)

Sends the command Select all to the window.

Del

{DEL}

Sends the command Delete to the window.

Ctrl + S

^(s)

Sends the command Save to the window.

Alt + F4

%{F4}

Sends the command Close window to the window.

TBox Send Keys example

TBox Window Operation

The Module TBox Window Operation sends specific commands to a window.

It has the following ModuleAttributes:

ModuleAttribute

Description

Caption

Caption of the window that you want to steer. This caption identifies the window.

Child Window Caption

Caption of the child window that you want to steer. This caption identifies the child window.

Operation

Command for steering the control. You can choose from the operations described in the table below.

Operation->Height

Required height of the window in pixel.

This ModuleAttribute is mandatory if you have selected the operation Resize.

Operation->Width

Required width of the window in pixel.

This ModuleAttribute is mandatory if you have selected the operation Resize.

Window Index

Specify the window that Tosca should apply the specified Operation to.

This ModuleAttribute is optional, but useful if the Caption that you have specified applies to more than one window. For instance if you use a wildcard.

Operations

Tosca supports the following operations:

Operation

Description

Bring To Front

Instructs Tosca to bring the window to the front.

Bringing a window to the front might take longer depending on the complexity of the window UI and your machine's performance. Tricentis recommends to add a TestStep after this operation so that Tosca waits until a control on the window is visible before executing the next TestStep, as shown in the example.

Close

Closes the window.

Maximize

Maximizes the window.

Minimize

Minimizes the window.

Move to Center

Moves the window to the center of the screen.

Normal

Restores the window to its original size.

Resize

Re-sizes the window to the height and width that you have specified in the ModuleAttributes Height and Width, respectively.

Try Bring To Front

Brings the window to the front but if unsuccessful goes on to your next TestStep. Your automation continues and Tosca shows the Try Bring To Front TestStep as failed.

Verify Window Exists

Verifies whether the specified window is open.

Verify Window Does Not Exist

Verifies whether the specified window is closed.

Wait On Close

This operation requires the ActionMode WaitOn.

It has two different behaviors:

  • If you use the operation by itself, Tosca waits for the time you defined in the setting Synchronization Timeout during WaitOn or until the window is closed - whichever happens first.

  • If you combine the operation with the ModuleAttribute Window Index, Tosca waits until the number of open Windows with the specified caption is lower than the value of Window Index.

Wait On Open

This operation requires the ActionMode WaitOn.

It has two different behaviors:

  • If you use the operation by itself, Tricentis Tosca waits for the time you defined in the setting Synchronization Timeout during WaitOn until the window is open.

  • If you combine the operation with the ModuleAttribute Window Index, Tosca waits until the number of open Windows with the specified caption is equal or higher than the value of Window Index.

In this example, you have more than one window open. The caption of all open windows starts with Test file.

You want to close the second window.

Close a specific window

In this example, you have a parent window and its child window open, and only maximize the child window.

Maximize a child window

In this example, you add a new TestStep after the Bring to Front operation. This TestStep ensures that Tosca waits with the execution of the next TestStep until the controls on the window are visible, that means the window is brought to the front.

  • You create a TestStep after the Bring to Front operation using the same Module that you used for the next TestStep, in this example, Automobile.

  • You set the ActionMode of the TestStepValue to WaitOn and specify the value Visible == True.

Wait for the window to be visible

TBox Scroll Window Operation

The Module TBox Scroll Window Operation allows you to define scrolling behavior.

It has the following ModuleAttributes:

ModuleAttribute

Description

Caption

Caption of the application window that Tosca should scroll. This caption identifies the application window.

Window Index

Specifies the window (based on the opening order) that Tosca should scroll.

This ModuleAttribute is optional, but useful if the Caption that you have specified applies to more than one window. For instance if you use a wildcard.

Vertical

Specifies in pixels (px) or lines (lines) how far Tosca scrolls along the vertical axis. If you specify a number without a unit of measurement, the page scrolls for the number of mouse wheel notches.

Horizontal

Specifies in pixels (px) or lines (lines) how far Tosca scrolls along the horizontal axis. If you specify a number without a unit of measurement, the page scrolls for the number of mouse wheel notches.

Note that this ModuleAttribute only works if horizontal scrolling is supported by the application window.

MousePolicy

Specifies where Tosca should position the mouse pointer during scrolling.

Enter one of the following values: Center (default), None.

DirectionPolicy

Specifies whether Tosca should scroll along the vertical or horizontal axis first.

Enter one of the following values: NoDirectionPolicy (default), HorizontalFirst, VerticalFirst.

Delay

Specifies the time in milliseconds (ms) that Tosca should wait between scrolling along the vertical and horizontal axis.

In this example, Tosca performs the following actions:

  • Identifies all open application windows that end with the caption - Notepad.

  • Scrolls third application window that ends with the caption - Notepad.

  • Scrolls 500px along the vertical axis.

  • Scrolls 1000px along the horizontal axis.

  • Mouse pointer is positioned in the center.

  • Scrolls along the horizontal axis first.

  • Waits 300ms until it scrolls along the vertical axis.

TBox Scroll Window Operation example

TBox Save As

The Module TBox Save As steers the dialog window Save As. To steer it, the Save As dialog has to be open.

It has the following ModuleAttributes:

ModuleAttribute

Description

Caption

Caption of the Save As dialog that you want to steer. Tricentis Tosca identifies the dialog from the caption in the upper section of the screen (WindowText). You can enter any string.

This ModuleAttribute is mandatory.

FileNameLabel

Label of the input field where you enter the path in the Save As dialog.

You only need to specify the label if the input field is NOT File name. If the label is File name, Tosca steers it automatically.

You can enter any string.

FilePath

Path where Tosca saves the file.

This ModuleAttribute is mandatory.

Button

Specify which button Tosca should click.

Tosca steers Save or Cancel automatically. You only need to specify the button if the button is NOT Save or Cancel.

This ModuleAttribute is optional.

ConfirmationPopupCaption

Caption of the modal dialog window. This allows you to steer modal dialog windows, for instance a confirmation dialog or an overwrite dialog if the file already exists.

You can only confirm the modal dialog.

Enter any string to specify the caption of the modal dialog.

This ModuleAttribute is optional.

ConfirmationPopupButton

Specifies the confirmation button in the dialog specified in the ModuleAttribute ConfirmationPopup. You can enter any string.

Tosca steers Ja, Yes, or OK automatically. You only need to specify the button if the button is NOT Ja, Yes, or OK.

 

This example shows how to steer a Save As dialog. Tosca Commander performs the following actions:

  • Identifies the Save as dialog

  • Saves the file test.txt to the path C:\Temp

  • If the file already exists, Tosca Commander confirms the overwrite in the Confirm Save As dialog.

TBox Save As example