Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Saturday 1 July 2023

Basic Windows Operations

Windows Operations allows you to perform special tasks in the Tosca. It contains the following modues.

  1. TBox Take Screenshot

  2. TBox Clipboard

  3. TBox Dialog

  4. TBox Send Keys

  5. TBox Window Operation

  6. TBox Save as

TBox Take Screenshot

TBox Take Screenshot 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:

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.

Example :: 

Take a screenshot of your desktop, Save it to the directory D:\Screenshots and Give this screenshot the name as Screen1.

Note - Module name is TBox Take Screenshot

TBox Clipboard

TBox Clipboard 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:

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.

Example

  • 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 Send Keys

The TBox Send Keys module sends the keyboard commands to any opened window or screen or web page.

The TBox Send Keys has the following ModuleAttributes:

Caption --  This is optional attribute, The captin of the window or page or screen to be steered is entered here.

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

Key - This module attribute specifies the value to be used for steering.

NOTE -- Always put keyboard commands in curly brackets between inverted commas.

Below are the command codes corresponding to the keys shown in the below table.

KeyCode
BACKSPACE{BACKSPACE}, {BS}, or {BKSP}
BREAK{BREAK}
CAPS LOCK{CAPSLOCK}
DEL or DELETE{DELETE} or {DEL}
DOWN ARROW{DOWN}
END{END}
ENTER{ENTER} or ~
ESC{ESC}
HELP{HELP}
HOME{HOME}
INS or INSERT{INSERT} or {INS}
LEFT ARROW{LEFT}
NUM LOCK{NUMLOCK}
PAGE DOWN{PGDN}
PAGE UP{PGUP}
PRINT SCREEN{PRTSC} (reserved for future use)
RIGHT ARROW{RIGHT}
SCROLL LOCK{SCROLLLOCK}
TAB{TAB}
UP ARROW{UP}
F1{F1}
F2{F2}
F3{F3}
F4{F4}
F5{F5}
F6{F6}
F7{F7}
F8{F8}
F9{F9}
F10{F10}
F11{F11}
F12{F12}
F13{F13}
F14{F14}
F15{F15}
F16{F16}
Keypad add{ADD}
Keypad subtract{SUBTRACT}
Keypad multiply{MULTIPLY}
Keypad divide{DIVIDE}

Example - 

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.



^(a) - Sends the command Select all to the window.

"{DEL}" - Sends the command Delete to the window.

^(s) - Sends the command Save to the window.

%"{F4}" - Sends the command Close window to the window.

TBox Window Operation

The TBox Window Operation Module can be used to send specific commands to a window relating to intended operation.

The TBox Window Operatin has the following ModuleAttributes:

CaptionThe captin of the window or page or screen to be steered is entered here.

OperationSpecify the command to be used for steering the control.

Operation->HeightThis is mandatory if you have selected the operation Resize. (Required height of the window in pixel).

Operation->WidthThis is mandatory if you have selected the operation Resize (Required width of the window in pixel.).

Window Index This is optional, but useful if the Caption that you have specified applies to more than one window. For instance if you use a wildcard. (Specify the window that Tricentis Tosca should apply the specified Operation to.)

Tricentis Tosca supports the following operations:

Bring To Front - Brings the window to the front.

CloseThis option closes the selected window.

MaximizeThis option maximizes the selected window.

MinimizeThis option minimizes the selected window.

Move to CenterMoves the window to the center of the screen.

Normal - Restores the window to its original size.

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

Verify Window ExistsThis option invokes the system to verify if a specific window is open.

Wait On CloseThis option makes the system wait for a specific period until a window is closed.

Wait On OpenThis option makes the system wait for a specific period until a window is Opened.

Example :  More than one window open. The caption of all open windows starts with Test fileYou want to close the second window.


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:

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

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 nameTosca Commander steers it automatically.You can enter any string.

FilePath - This is mandatory. Path where Tosca Commander saves the file.

ButtonThis is optional. 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.

ConfirmationPopupCaption - This is optional.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.

ConfirmationPopupButton - Specifies the confirmation button in the dialog specified in the Attribute ConfirmationPopup. You can enter any string.Tosca Commander steers JaYes, or OK automatically. You only need to specify the button if the button is NOT JaYes, or OK.


Example : - 

  1. Identifies the Save as dialog

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

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


String Operations

In Tosca, Use dynamic expressions to modify and verify data in strings. If your string contains special characters, you have to escape them. You can also use dynamic expressions with string operations.


STRINGTOLOWER-- Converts uppercase characters in the string to lowercase characters.

Syntax: {STRINGTOLOWER[InputText]}

Example 

{STRINGTOLOWER[Nice Day]} 

Ans:

nice day


STRINGTOUPPER -- Converts lowercase characters in the string to uppercase characters.

Syntax: {STRINGTOUPPER[InputText]}

Example : 

{STRINGTOUPPER[Nice Day]}

Ans: 

NICE DAY

TRIM-- Removes whitespace characters from the start or the end of the string, or both:

  • If you don't use an optional parameter, the expression removes whitespace characters from both the start and the end of the string (default).

  • If you use the optional parameter [START], Tricentis Tosca removes whitespaces from the start of the string.

  • If you use the optional parameter [END], Tricentis Tosca removes whitespaces from the end of the string.


Syntax: {TRIM[InputText][Optional Parameter]}

Example -- 

{TRIM[ no starting space ][START]}

Ans

no starting space

BASE64--- Parameter ENCODE encodes the string to Base64 format, parameter DECODE decodes the Base64 string.

Syntax: {BASE64[InputText][Parameter]}

Exampele

{BASE64[Hello][ENCODE]}

Ans SGVsbG8=



STRINGREPLACE-- Replaces all occurrences of a defined input or pattern with a new defined value.

  • If you use the optional parameter [REPLACEFIRST], Tricentis Tosca only replaces the first occurrence.

  • If you use the optional parameter [IGNORECASE], Tricentis Tosca ignores the letter case during the search.


Syntax: {STRINGREPLACE[InputText][Pattern][NewValue][Optional parameter1, Optional parameter2]}

Example

{STRINGREPLACE[WeekEnd][e][x][IGNORECASE]}

Ans -

Wxxkxnd

NUMBEROFOCCURRENCES-- Counts all occurrences of the defined input or pattern in the string.

If you use the optional parameter [IGNORECASE], Tricentis Tosca ignores the letter case during the search.


Syntax: {NUMBEROFOCCURRENCES[InputText][Pattern][Optional parameter]}


Example -- 

{NUMBEROFOCCURRENCES[Mississippi][ss]}


Ans- 

2


STRINGLENGTH-- Counts the number of characters in the string.


Syntax: {STRINGLENGTH[InputText]}


Example - 


{STRINGLENGTH[Nice2MeetU]}


Ans- 


10


String operations with dynamic expressions

You can use string operations with specific text-based dynamic expressions.This allows you to include buffers, date and time expressions, and random numbers in a string operation

To use string operations with dynamic expressions, replace the respective [InputText] of a string operation with the desired dynamic expression.


Using a buffered value in a string operation - 

TBox Clipboard (Read) -   

This TestStep buffers the content of the system clipboard to a buffer called ClipBuffer.

TBox Clipboard (Write)- 

This TestStep  uses the buffered content with the string operation {STRINGTOUPPER} to capitalize it.

in the below Value field, {STRINGTOUPPER[{B[ClipBuffer]}]



Example - 

 Use the string operation {STRINGREPLACE} to replace the number 2021 with 21

in the value field - {STRINGREPLACE[{DATE}][2021][21]}