# The String Field¶

When a component in a test case object matches an area currently onscreen, its Action will be executed, and then the contents of its String field will be typed out as a sequence of keystrokes, one at a time, to the window in focus when the test case object matched.

The text that is inserted may come from multiple sources, in which case the String field specifies how they should be combined (examples can be found in the next section below):

• Manually specified on the test case object itself:

• Regular characters: Normal letters and numbers, along with most punctuation

• Special characters: Non-printable characters (see table below), such as Enter and Control, along with punctuation that has special meaning such as for regular expressions

• System keys: Special key combinations (see table below) for the operating system, such as Win+E to open a new Explorer window.

• Text read dynamically from the screen (scraped), computed by one test case object and then inserted as specified by another test case object that comes later in the script’s execution:

• Full text: The source is the entire text found in a region of interest specified by the earlier test case object

• Grouping with Regular Expressions: Insert substrings by applying a grouped regular expression to the string scraped from a region of interest

• Mapping extracted text: Given a Map, extract text from a region of interest, pass it to the map, and insert the map’s output value as specified by a later test case object

• External sources:

• Map values: The source of the text is fields in the Map itself

• CLI arguments: Text derived from command line parameters passed to Alyvix Robot

The extraction and mapping functions have a common purpose: to substitute text from source string into a template string, and then send the resulting string to the application.

If the text is supposed to come from the screen, the pattern is typically to have two separate test case objects, one which acquires the text from the screen, and another containing the template which inserts it into the GUI object. Otherwise, only a single object is necessary.

Usage Examples

To indicate that content in the String field template is not regular text, it must be escaped with a pair of curly braces { ... }. If you want to insert more than one template, each one must go in its own separate set of curly braces.

Note

For the purposes of scraping and mapping text, matching is applied in a case insensitive fashion. However, the result is stored (and later retrieved) with the case of the original characters.

The following examples provide an illustration of how these string functions can be applied.

Mixing Regular and Special Characters

Regular letters and numbers, along with most punctuation and special characters can be inserted in the String field normally. However, some special characters, editing keys, and key combinations must be escaped. The table below lists an extensive set of special keys.

In the following example, a test case object with an Excel® spreadsheet as a target would put the words “First”, “Second” and “Third” in three adjacent columns.

First{Tab}Second{Tab}Third


Full Text

When a text component matches an area onscreen, all of the text in its Region of Interest is scraped and stored. This text can be used by the test case objects in later scripting nodes to insert strings into GUI fields. The entire text can be inserted using the syntax {<test-case-object-name>.text}. So if a test case object named temperature_read reads the string 37 degrees in the application, it can be copied to another GUI field by putting the following expression in the String field of a later scripting node:

{temperature_read.text}


Grouping with Regular Expressions

More complex regular expressions can be used to select groups of subexpressions (like Python's grouping mechanism ) within the scraped text. These subexpressions can then be embedded within a new string template (even changing their relative order) by using the numbers of their original positions as follows:

{2} found near {1}


Mapping Extracted Text

Given a map with pairs of inputs to match and their corresponding output values, you can match text scraped from a previous test case and insert the map’s output value for that text. On the first test case object’s component (which must be of type text), the type must be set to MAP and the map’s name must be chosen in the dropdown Map. In the String field on the later test case object, the map’s output value can be retrieved with the template {<test-case-object-name>.extract}.

For instance, if the string Paris from the test case object city is read from the screen, and the selected map contains the pair Paris, France then the following template will generate the text Country:  France.

Country:  {city.extract}


Map values

This option allows you to create a map with a table of values (where each row corresponds to one iteration of the loop). For instance, you could insert three values per row into a table on a web page or in a spreadsheet with this String field entry:

{1}{Tab}{2}{Tab}{3}


CLI Arguments via the Alyvix Robot --args parameter

Text can also be inserted from a command line parameter passed to Alyvix Robot.

To use this capability, pass Alyvix Robot the argument as a simple keyword after the -a parameter to, and type the {<number>} notation into the String field of the test case object that should insert the text. For instance in the string below, passing the parameter -a Red will result in the text Color: Red appearing in the target text field of the application.

Color: {1}


Table of Special Characters

The following table details which keys and characters require escaping when used:

 Key Sequence Result {Enter} Enter key {Space} Space key (this is only needed at the beginning or the end of a string) {Tab} Tab key {Shift Down}, {Shift Up} {Shift Down} holds the Shift key down until {Shift Up} is encountered, so that all letters between them are shifted to upper case. {LShift} specifies the left Shift key and {RShift} specifies the right one. {Shift} Press and immediately release the Shift key, without applying it to the letters that come next. {Ctrl Down}, {Ctrl Up} {Ctrl Down} holds the Control key down until {Ctrl Up} is encountered, so that all characters in between have the Control function applied. {LCtrl} specifies the left Control key, and {RCtrl} the right. {Ctrl} Press and immediately release the Control key, without applying it to the characters that come next. {Alt Down}, {Alt Up} {Alt Down} holds the Alt key down until {Alt Up} is encountered, so that all characters in between have the Control function applied. {LCtrl} specifies the left Control key, and {RCtrl} specifies the right one. {Alt} Press and immediately release the Alt key, without applying it to the characters that come next. {LWin Down}, {LWin Up} {LWin Down} holds the left WindowsLogo key down until {LWin Up} is encountered {Backspace} Backspace key {Del} Delete key {Esc} Escape key {F1} - {F24} Function keys {Up} Up arrow key {Down} Down arrow key {Left} Left arrow key {Right} Right arrow key {Home} Home key {End} End key {PgUp} Page Up key {PgDn} Page Down key {U+nnnn} A unicode character , where nnnn is its hexadecimal value, excluding the 0x prefix {U+0060}  {U+0026} & {U+0022} “ {!} ! {#} # {^} ^ {+} + {{} { {}}` }

All other printable keys not found in the above list can be used normally.