ScriptBuilder Functions
  • 3 Minutes to read
  • Dark
    Light
  • PDF

ScriptBuilder Functions

  • Dark
    Light
  • 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 button 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.

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'

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

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', 'Org') = 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'

Find

Returns the position of a specified sub string within a given string.

Syntax - Find( find_text, within_text )

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


Number Functions

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) = '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

Syntax - Today()

Example - Today() + 1

Now

Return the current date and time

Syntax - Now()

Example - Now()

Last day of the month

Returns the last day of the month of the given date

Syntax - Last_day_of_month(Date*)

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

Day_of

Returns the day of the given date

Syntax - Day_of(Date*)

Example - Day_of("13/1/2018") = 13

Month_of

Returns the month of the given date

Syntax - Month_of(Date*)

Example - Month_of("13/1/2018") = 1

Year_of

Returns the year of the given date.

Syntax - Year_of(Date*)

Example - Year_of("13/1/2018") = 2018

Day_of_week

Returns the day of week of the given date.

Syntax - Day_of_week(Date*)

Example - Day_of_week("13/1/2018") = 7

Date

Returns a date which is constructed from the given day, month 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.