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 execution, you can view the screenshot in the Detail column of the ExecutionEntry.

The Module TBox Take Screenshot has the following ModuleAttributes:

ModuleAttribute

Description

Environment

Select from the drop-down menu whether you want to take a screenshot of your desktop or mobile device .

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

Directory

Path to the screenshot.

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

Filename

Name of the screenshot.

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

In this example, you perform the following actions:

  • Take a screenshot of your desktop.

  • Save it to the directory D:\Screenshots.

  • Give this screenshot the name Screen1.

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 text that's in your clipboard or to save that text to a buffer.

It has the following ModuleAttribute:

ModuleAttribute

Description

Value

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

Depending on the desired action, use ActionMode Input, Verify, or Buffer, 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 Tricentis 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 steers Win32 context menus.

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

  • Customized context menus: you need to scan them first.

The Module TBox Context Menu has the following ModuleAttributes:

ModuleAttribute

Description

Menu

Menu control representing the context menu that you want to steer. TBox Context Menu will steer whichever Win32 context menu is currently open based on the last right-click action.

Note that you can use wildcards when you specify the names of menu sub-items.

The TestStep performs the following actions:

  • Identifies the currently open Win32 context menu.

  • Selects a menu item called Properties.

TBox Context Menu example: steers context menu item Properties

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

Caption of the window that you want to steer. This is optional. If you enter a caption, Tricentis 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.

Tricentis 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, Tricentis Tosca sends the keys inverted. For example, if you want to send Abc and have CAPS LOCK on, Tricentis Tosca sends aBC.

If you use special characters in your commands, you need to escape them. For more information, see chapter "Special characters".

If your command contains a string with Microsoft SendKeys-specific special characters, you have to escape these too, according to the Microsoft SendKeys documentation (see Example 2).

Example 1

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

The double quotation marks that enclose specific commands escape the special characters within the command.

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

Example 2

In this example, you send the following string: "{B[Buffer]}". This string contains:

  • Microsoft SendKeys special characters: {, }, [, and ].

  • Characters that require special escaping in Tosca: ".

Microsoft SendKeys uses curly brackets { } to escape special characters. Tricentis Tosca uses double quotation marks " " to escape special characters. To escape all special characters, perform the following steps:

  1. Enclose the {, }, [, and ] characters with curly brackets. This way, Microsoft SendKeys considers these characters in the Buffer as part of the string: {{}B{[}Buffer{]}{}}.

  2. Add double quotation marks before each " character. This guarantees that Tosca treats the subsequent " character as part of the string: ""{{}B{[}Buffer{]}{}}"".

  3. Enclose the whole string with double quotation marks to escape the string for Tosca: """{{}B{[}Buffer{]}{}}""".

With the escaped special characters, TBox Send Keys interprets the TestStepValue """{{}B{[}Buffer{]}{}}""" as "{B[Buffer]}".

String with Buffer and special characters

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.

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 Tricentis 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

Tricentis 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.

Verify Window Exists

Verifies whether the specified window is open.

Wait On Close

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 or until the window is closed - whichever happens first.

  • If you combine the operation with the ModuleAttribute Window Index, Tricentis 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, Tricentis 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 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 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 Commander steers it automatically.

You can enter any string.

FilePath

Path where Tosca Commander saves the file.

This ModuleAttribute is mandatory.

Button

Specify which button Tosca Commander should click.

Tosca Commander 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 Commander 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