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

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]}