Data Generator APIs
The Data Generator APIs create random test data such as text, phone numbers, numbers, email addresses, dates, and booleans, for use anywhere in a script.
Generate Text
Section titled “Generate Text”Modes BrowserWindowsJavaAndroidiOSSAP
Generates random text data based on the given parameters.
Parameters
| Name | Type | Description |
|---|---|---|
$prefix | stringoptional | Text to prepend to the generated value |
$minLength | integeroptional | Minimum length of the generated text |
$maxLength | integeroptional | Maximum length of the generated text |
$suffix | stringoptional | Text to append to the generated value |
$includeAlphabet | booleanoptional | If true, the generated text includes alphabet characters |
$includeNumeric | booleanoptional | If true, the generated text includes numeric characters |
$includeSpecial | booleanoptional | If true, the generated text includes special characters |
$addTimestamp | booleanoptional | If true, appends a timestamp to the generated value |
Returns
string | The generated text value |
Raw script
var $text = _generateText("txt_", 5, 10, "_end", true, true, false, false);Sahi Pro Classic API _generateText
Generate Phone Number
Section titled “Generate Phone Number”Modes BrowserWindowsJavaAndroidiOSSAP
Generates a random phone number based on the given formats.
Parameters
| Name | Type | Description |
|---|---|---|
$formats | arrayoptional | List of phone number formats to generate from, e.g. "+xx (xxx) xxx-xxxx", "xxx-xxx-xxxx" |
Returns
string | The generated phone number |
Raw script
var $phone = _generatePhoneNumber(["xxx-xxx-xxxx"]);Sahi Pro Classic API _generatePhoneNumber
Generate Number
Section titled “Generate Number”Modes BrowserWindowsJavaAndroidiOSSAP
Generates a random number based on the given parameters.
Parameters
| Name | Type | Description |
|---|---|---|
$prefix | stringoptional | Text to prepend to the generated value |
$minValue | integeroptional | Minimum value of the generated number |
$maxValue | integeroptional | Maximum value of the generated number |
$decimals | integeroptional | Number of decimal places in the generated number |
$separator | stringoptional | Thousands separator to use in the generated number |
$decimalSeparator | stringoptional | Decimal separator to use in the generated number |
$suffix | stringoptional | Text to append to the generated value |
Returns
string | The generated number |
Raw script
var $number = _generateNumber("$", 1, 100, 2, ",", ".", "");Sahi Pro Classic API _generateNumber
Generate Email
Section titled “Generate Email”Modes BrowserWindowsJavaAndroidiOSSAP
Generates a random email address based on the given parameters.
Parameters
| Name | Type | Description |
|---|---|---|
$names | arrayoptional | List of names to use while generating the email address |
$domains | arrayoptional | List of domains to use while generating the email address |
$excludes | arrayoptional | List of email addresses to exclude from generation |
$addTimestamp | booleanoptional | If true, appends a timestamp to the generated email address |
Returns
string | The generated email address |
Raw script
var $email = _generateEmail(["john"], ["example.com"], [], true);Sahi Pro Classic API _generateEmail
Generate Date
Section titled “Generate Date”Modes BrowserWindowsJavaAndroidiOSSAP
Generates a random date based on the given parameters.
Parameters
| Name | Type | Description |
|---|---|---|
$from | dateoptional | From date value for the generated date |
$to | dateoptional | To date value for the generated date |
$format | stringoptional | Format to use for the generated date |
Returns
string | The generated date |
Raw script
var $date = _generateDate("2020-01-01", "2020-12-31", "yyyy/MM/dd");Sahi Pro Classic API _generateDate
Generate Boolean Value
Section titled “Generate Boolean Value”Modes BrowserWindowsJavaAndroidiOSSAP
Generates a random boolean value based on the given default value.
Parameters
| Name | Type | Description |
|---|---|---|
$defaultValue | booleanoptional | Default value to use for the generated boolean |
Returns
boolean | The generated boolean value |
Raw script
var $flag = _generateBooleanValue(true);Sahi Pro Classic API _generateBooleanValue

