Nexial Automation

Test Automation Platform for everyone!

X

$(array)

Description

This built-in function provides various capabilities regarding array (ie. a list of things).  Note that in Nexial there really isn’t a prescriptive way of defining an array.  It is simply a string, or a contiguous character, separated by delimiter that is defined via thenexial.textDelim predefined variable.  For example,

The above script defines an array of 6 elements (iconpicturediagramchartscreen, and image), and this array is referenced by a variable named array1.

The above script defines an array of 2 elements ( Smith, John and Appleseed, Johnny) - the delimiter defined on the first row is the pipe character (|), not comma. As pipe character (|) is separator for built-in function parameters, we have to escape pipe character for array. As you can show in above image, array1 has value Smith, John\|Appleseed, Johnny with pipe character escaped.

By default, nexial.textDelim has the value of a comma (,).

Available Functions

$(array|append|input|item)

Add an element (item) to the beginning of the target array (input), and then render the resulting array.

Example
Script

Output


$(array|ascending|input)

Renders the target array (input) in ascending order. The order is determined lexicographically via the ASCII values of the array elements.

Example
Script

Output


$(array|descending|input)

Renders the target array (input) in descending order. The order is determined lexicographically via the ASCII values of the array elements.

Example
Script

Output


$(array|distinct|input)

Renders the target array (input) by removing duplicated elements.

Example
Script

Output


$(array|index|input|item)

Renders the position within the target array (input) where the first occurrence of a specified element (item) is found.  For example, $(array|index|Apple,Orange,Banana|Orange) would return 1.   Note that Nexial is zero-based.

Example
Script

Output


$(array|insert|input|index|item)

Add an element (item) into the target array (input), at the specified position (index), and then render the resulting array.

Example
Script

Output


$(array|item|input|index)

Renders the element (item) of the specified position (index, zero-based) in the target array (input).   For example, $(array|item|Salt,Pepper,Sugar,Cheese|3) would render Cheese

Example
Script

Output


$(array|length|input)

Renders the length of the target array (input).  An empty array would render 0.

Example
Script

Output


$(array|pack|input)

Remove all empty or null items in the array.

Example
Script

Output


$(array|prepend|input|item)

Add an element (item) to the end of the target array (input), and then render the resulting array.

Example
Script

Output


$(array|remove|input|index)

Remove an element (item) from the array (input), at the specified position (index), and then render the resulting array.

Example
Script

Output


$(array|replica|input|count)

Transform the current array to multiple copies of itself (append the array to itself).  The  count is used to specify the number of times to repeat.  For example, $(array|replica|a,b,c|2) would yield a array of a,b,c,a,b,c.

Example
Script

Output


$(array|replicaUntil|input|size)

Transform the current array to multiple copies of itself (append the array to itself), until the length of the array is the same as size.  For example, $(array|replicaUntil|a,b,c|7) would yield a list of a,b,c,a,b,c,a.

Example
Script

Output


$(array|reverse|input)

Renders the array (input) in its reversed order.

Example
Script

Output


$(array|subarray|input|start|end)

Renders a portion of the target array (input), based on the specified start and end positions. One may specify end as -1 to signify the last position of the target array.

Example
Script

Output