TextStream Modules

The folder TBox XEngines->TextStream in the Standard subset contains Modules that perform specific tasks for the TextStream Engine 3.0.

TextStream Open/Load

The Module TextStream Open/Load allows you to open a TextStream. Additionally, you can load content from an external source into the TextStream that you specify.

It has the following ModuleAttributes:

ModuleAttribute

Description

Stream Name

The name of the TextStream which you want to open or load content into.

Load Source Type

Optionally, you can use this ModuleAttribute to load content from an external source into the specified TextStream. To do so, choose one of the following sources as a value:

  • Clipboard: loads content from the system clipboard.

  • File: loads content from a file you specify.

  • Buffer: loads content from a buffer you specify.

Load Source Identifier

If you specified the value File or Buffer for the ModuleAttribute Load Source Type, use this to specify the complete path to the file or the buffer name.

Load Operation Type

The type of operation you want to perform when you load content into the TextStream. You can specify the following operation types as a value for this ModuleAttribute:

  • Replace: replaces the current TextStream content with the content from the specified source. This is the default value.

  • Append: appends the content from the specified source to the end of the current TextStream, without creating a new line.

  • Append to New Line: creates a new line in the current TextStream and appends the content from the specified source to it.

Line Separator

Line separator setting for the TextStream. You can specify the following line separators, which depend on the Operating System (OS) under test:

  • Windows (default value)

  • Unix

  • Legacy Mac OS

In this example, you perform the following actions:

  • You open and replace the content of a TextStream called TestStream.

  • The source of the new content is an external file, located at C:\Temp\test.txt.

  • You replace the content of the TextStream with the Windows (CR-LF) line separator setting.

Open a TextStream and load content from an external source

TextStream Save/Close

The Module TextStream Save/Close allows you to close a TextStream and optionally, save its content to an external destination.

It has the following ModuleAttributes:

ModuleAttribute

Description

Stream Name

The name of the TextStream which you want to close or save.

Destination Type

The destination where you want to save your TextStream. You can specify the following destinations as a value for this ModuleAttribute:

  • Clipboard: saves the content to the system clipboard. This is the default value.

  • File: saves the content to a file you specify.

  • Buffer: saves the content to a buffer you specify.

  • None: doesn't save the content.

Destination Identifier

If you specified the value File or Buffer for the ModuleAttribute Destination Type, use this to specify the complete path to the file or the buffer name.

Encoding

Choose a text encoding option from the dropdown menu. The default value is UTF-8.

Keep Stream Open

Tricentis Tosca closes the TextStream by default. If you want to leave it open after saving, set this value to True.

In this example, you save the TextStream called TestStream to the system clipboard without closing it.

Save the content of a TextStream to an external source

TextStream Block Text Manipulation

The Module TextStream Block Text Manipulation allows you to manipulate the content of a TextStream as a single block of text.

It has the following ModuleAttributes:

ModuleAttribute

Description

Stream Name

The name of the TextStream which you want to manipulate.

Target Line

Specifies which line of text to load from the TextStream. You can specify one of the following values:

  • An integer <n>: loads the specified line. For example, the value 2 loads the second line of the text.

  • One or more strings separated by a semicolon (;) <string1>;<string2>;<...>: loads the first line which contains all the strings you specify.

If you don't specify a Target Line value, Tricentis Tosca uses one of the following defaults based on the Input Operation Type:

  • 1 for Replace and Append.

  • #last for Append to New Line.

Input Operation Type

If you use ActionMode Verify for the Content ModuleAttribute , leave the value of this ModuleAttribute empty.

If you use ActionMode Input for the ModuleAttribute Content, choose an operation to perform when you insert the specified content into the TextStream.

You can specify the following operation types as a value for this ModuleAttribute:

  • Replace: replaces the current TextStream content with the specified content.

  • Append: appends the specified content to the end of the specified Target Line. This is the default value.

  • Append to New Line: creates a new line in the current TextStream and appends the specified content to it.

Field Separator

Specifies the character that separates your values in your Target Line. For instance, a semicolon (;) is the separator of the following example: <Name>;<Age>;<Country>.

This ModuleAttribute is optional.

Line Length

Specifies the maximum number or characters of the Target Line.

This ModuleAttribute is optional.

Total Field Count

Specifies the number of fields in your TextStream, based on the Field Separator ModuleAttribute.

This ModuleAttribute is optional.

Content

Specifies the text content that you want to steer. Note the following when you specify the content of your TextStream:

  • You can have multiple Content ModuleAttributes in the same Module. To do so, copy and paste this ModuleAttribute into the Module as many times as required.

  • By default, this ModuleAttribute is a TextBox. To use it as a ListBox, you can change the default parameter BusinessType of this ModuleAttribute to ListBox. This is particularly helpful if you want to steer multiple text fields as a list.

Optionally, you can add the following configuration parameters to this ModuleAttribute:

  • AlignToRight: set this configuration parameter to True to align characters to the right. By default, Tricentis Tosca aligns text fields to the left.

  • Length: specifies the maximum number of characters for this ModuleAttribute.

  • Offset: specifies the number of characters to offset starting from the first character of the Target Line.

  • Position: specifies the position of this Content (as an integer) in relation to the other fields, if you use a Field Separator. For instance, if you specify the value 2, Tricentis Tosca locates the specified Content in the second available field of the specified Target Line.

In this example, you append new content to the last line of a TextStream called TestStream. It has four different fields, which use a semicolon as a separator.

In the TestStep Block Text Manipulation - Input, you perform the following actions:

  • You insert the Student ID TRIC102-X into the TextStream. The corresponding ModuleAttribute has the following additional configuration parameters:

    AlignToRight set to True

    Length set to 15

    Position set to 1

  • You insert the Student Name Jane Doe into the TextStream. The corresponding ModuleAttribute has the following additional configuration parameters:

    Length set to 15

    Offset set to 21

    Position set to 2

  • You insert the Course Name programming into the TextStream. The corresponding ModuleAttribute has the following additional configuration parameters:

    Length set to 20

    Offset set to 37

    Position set to 3

  • You insert the Course Start Date 01/02/2019 into the TextStream. The corresponding ModuleAttribute has the following additional configuration parameters:

    Length set to 10

    Offset set to 58

    Position set to 4

The steps above produce the following TextStream:

TestStream after manipulation

In the TestStep Block Text Manipulation - Verify, you verify the contents of all fields which you inserted with the previous TestStep.

Manipulate the content of a TextStream

TextStream Table Text Manipulation

The Module TextStream Table Text Manipulation allows you to manipulate the content of a TextStream which is formatted as a table.

It has the following ModuleAttributes:

ModuleAttribute

Description

Stream Name

The name of the TextStream which you want to manipulate.

Start Line

Line number of the first line of text that you want to load from the TextStream.

This ModuleAttribute is optional.

End Line

Line number of the last line of text that you want to load from the TextStream.

This ModuleAttribute is optional.

Input Operation Type

If you use ActionMode Verify for the ModuleAttribute Content, leave the value of this ModuleAttribute empty.

If you use ActionMode Input for the ModuleAttribute Content, choose an operation to perform when you insert the specified content into the TextStream.

You can specify the following operation types as a value for this ModuleAttribute:

  • Replace: replaces the current TextStream content with the content you specify. This is the default value.

  • Append: appends the specified content to the end of the current TextStream. If you specified a Start Line or an End Line, it appends the specified content to the end of the last available line.

Column Definition Value

The value that specifies the columns of the tabulated text content. You can specify the following column separators as a value for this ModuleAttribute:

  • <SPACE> and <TAB>: special column separator values which represent their white space equivalents. The default value is <SPACE>.

  • An integer greater than 0: specifies a fixed column width of that number of characters for every column.

    You can optionally specify an offset in square brackets ([<offset>]). The reference for the offset is the first character of the loaded line content.

    Examples: 15 or 15[21]

  • A set of integers greater than 0, separated by a semicolon (;): individually specifies the column width for each column.

    You can optionally specify an offset in square brackets ([<offset>]). The reference for the offset is the first character of the loaded line content.

    Examples: 3;15;15;10 or 3[13];15[21];15[44];10[59]

  • Any character or character sequence other than an integer greater than 0 specifies a variable column width. For example, if you specify a character such as #, Tricentis Tosca interprets each of those as a column.

Content

The table content that you want to steer.

In this example, you perform the following actions:

  • You replace the tabulated content of a TextStream called TestStream, which separates its columns using a space character.

  • You load the content from lines 1 to 4 and replace the text in the third row of the second column.

Manipulate tabulated content in TextStream