ScriptBuilder Functions
  • 4 Minutes to read
  • PDF

ScriptBuilder Functions

  • PDF

Article summary

Panaya's test automation scriptBuilder offers a comprehensive range of functions designed to streamline and enhance the automation process.
Functions are accessible when adding new parameters, when validating instructions and in many other areas of scriptBuilder.

Keep the Expression checkbox selected so Panaya can evaluate the input as an expression. Text inputs are not evaluated and are treated as string tests.

Text Functions

Left

Left returns the first character or characters in a text string based on the number of characters you specify.

Syntax - Left('text', [num_chars])

Example - Left('Sale Price', 4) = 'Sale'

Right

Right returns the last character or characters in a text string based on the number of characters you specify.

Syntax - Right('text',[num_chars])

Example - Right('Sale Price', 5) = 'Price'

Mid

Mid returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify. The starting position begins from 0.

Syntax - Mid('text', start_num, num_chars)

Example - Mid('Fluid Flow',0,5) = 'Fluid'

If start_num is greater than the length of text, Mid returns '' (empty text).

If start_num is less than the length of text, but start_num plus num_chars exceeds the length of text, Mid returns the characters up to the end of text.

Concatenate 

The concatenate function joins two text strings into one string.

Syntax - Concatenate('text1', 'text2')

Example - Concatenate('Sale', ' Price') = 'Sale Price'

Contains

Determines whether the value parameter occurs within this string, or if value is the empty string, and returns TRUE/FALSE

Syntax - Contains('text', value)

Example - Contains('Original Text', 'nal') = True

Starts_with

Determines whether the beginning of the text matches value parameter and returns TRUE/FALSE

Syntax - Starts_with('text', value)

Example - Starts_with('Original Text', 'Ori') = True

Ends_with

Determines whether the end of the text matches value parameter and returns TRUE/FALSE

Syntax - Ends_with('text', value)

Example - Ends_with('Original Text', 'xt') = True

Len

Returns the length of a string

Syntax - Len('text')

Example - Len('Text') = 4

Str_to_num

Returns the number that is the representation of the specified string based on the script settings

Syntax - Str_to_num('text')

Example - Str_to_num('-1,234.56') = -1234.56

Num_to_str

Returns the string that represents the specified number based on the script settings.

Syntax - Num_to_str(number)

Example - Num_to_str(-1234.56) = '-1234.56'

Upper

Returns the string with all letters capitalized.

Syntax -
upper('Text') = TEXT

The function will return an error if the input is numeric (without ' ').

Lower

Returns the string without capitalization.

Syntax -
lower('Text') = text

The function will return an error if the input is numeric (without ' ').

Find

The find function returns the position of a specified character or sub-string within a supplied text string.

Syntax - Find('find_text', 'within_text')

Example - Find( 'T', 'Original Text' ) = 10


Number Functions

Strings vs. Numbers

Strings and numbers cannot be directly compared in expressions ('123' > 23 is invalid). Always compare numbers to numbers or strings to strings.

  • Use num_to_str or str_to_num to convert values when necessary.

  • Digits captured from the screen (e.g., 123) are treated as numbers.

  • Functions like Left(123,1) return a string ('1'), which cannot be compared with numbers.

Min

Min function returns the smallest value in 2 given values.

Syntax - Min(num1, num2)

Example - Min(10,2) = 2

Arguments can either be numbers or expressions that return a number.

Entering more or less than 2 arguments will cause an error.

Max

Max function returns the largest value in 2 given values.

Syntax - Max(num1, num2)

Example - Max(10,2) = 10

Arguments can either be numbers or expressions that return a number.

Entering more or less than 2 arguments will cause an error.

Random

Returns a random number within a specified range.

Syntax - Random(min_value,max_value)
Example - Random(2,10) = 7

Abs

Returns the absolute value of a specified number.

Syntax - Abs(number)

Example - Abs(-5) = 5

Ceiling

Returns the smallest integer greater than or equal to the specified number.

Syntax - Ceiling(number)

Example - Ceiling(3.2) = 4

Floor

Returns the largest integer less than or equal to the specified number.

Syntax - Floor(number)

Example - Floor(3.8) = 3

Round

Rounds a value to the nearest integer or specified number of decimal places.

If the number_of_decimals is greater than 0, it will return a value to the nearest integer or the specified number of fractional digits. If the number_of_decimals equals 0, the closest integer number will be returned. A negative number_of_decimals will return an error.

Syntax - Round(number,number_of_decimals)

Example - round(3.5,0) = 4

Sign

Returns a value indicating the sign of a number.
It returns 1 for positive numbers, 0 if the value is 0, and -1 for negative numbers.

Syntax - Sign(number)

Example - Sign(-7) = -1

Truncate

Calculates an integral part of a number.

Syntax - Truncate(number)

Example - Truncate(3.9) = 3

In

In Returns, whether an element is in a set of values.

Syntax - In(value,value1,value2,...)

Example - In(5, 1, 10, 5, 3) = 'True'

If

If Returns a value based on a condition.

Syntax - If(condition, true_value, false_value)

Example - If(5 > 3, 'Yes', 'No') = 'Yes'


Date Functions

Today

Returns the current date. The date format matches the script date format.

Syntax - Today()

Example - Today() + 1

Now

Returns the date in the script date format and the time (hour:minute: seconds) separated by a space, as shown in the example below.

Syntax - Now()

Example - Now()

Last day of the month

Returns the last day of the month of the given date. The date inputted should match the defined script date format.

Syntax - Last_day_of_month('Date')

Example - Last_day_of_month('1/13/2018') = 31

Day_of

Returns the day of the given date. The date inputted should match the defined script date format.

Syntax - Day_of('Date')

Example - Day_of('1/1/2025') = 1

Month_of

Returns the month of the given date. The date inputted should match the defined script date format.

Syntax - Month_of('Date')

Example - Month_of('1/5/2025') = 1

Year_of

Returns the year of the given date. The date inputted should match the defined script date format.

Syntax - Year_of('Date')

Example - Year_of('13/1/2025') = 2025

Day_of_week

Returns the day of the week of the given date. The date inputted should match the defined script date format.

Syntax - Day_of_week('Date')

Example - Day_of_week('1/12/2025') = 1

Date

Returns a date constructed from the given month, day, and year.

Syntax - Date(arg1,arg2,arg3)

Example - Date(1,13,2018) = 1/13/2018 (When date format is MM/DD/YYYY)

Note

The date format should match the Script Setting format.