Generic keywords
CompressGzip
Full name: org.getopentest.actions.compression.CompressGzip
Compresses a file, a byte sequence or a string into a GZip package.
| The full path to the file to compress. Default: |
| A byte array to compress. This has to be a native Java |
| A string to compress. The string will be first converted into the equivalent byte array, using the UTF-8 encoding. Default: |
| If the intention is to save the compressed data in a file on disk, this argument must point to the full path to the file. Default: |
Output values:
| A byte array containing the GZip-compressed bytes, as a native Java |
Example:
- description: Compress some string data to GZip
action: org.getopentest.actions.compression.CompressGzip
args:
sourceString: Some data to compress
$localData:
gzipBytes: $output.compressedBytes
DecodeBase64
Full name: org.getopentest.actions.codecs.DecodeBase64
Decodes Base64 data.
| The full path to the file containing the Base64 string to decode. Default: |
| A byte array containing the Base64 data to decode. The text is expected to contain the UTF-8 bytes of the Base64 string to decode. This has to be a native Java |
| A string to decode. Default: |
| If the intention is to save the decoded data in a file on disk, this argument must point to the full path to the file. Default: |
Output values:
| A byte array containing the decoded bytes, as a native Java |
Example:
- description: Decode some string data to GZip
action: org.getopentest.actions.codecs.DecodeBase64
args:
sourceString: U29tZSBzdHJpbmcgdG8gZW5jb2Rl
$localData:
utf8Data: $output.decodedBytes
- description: Decode the UTF-8 byte into a string
action: org.getopentest.actions.codecs.DecodeUtf8
args:
sourceBytes: $localData.utf8Data
$localData:
originalString: $output.decodedString
DecodeUtf8
Full name: org.getopentest.actions.codecs.DecodeUtf8
Decodes UTF-8 data into the corresponding string.
| A byte array containing the UTF-8 data to decode. This has to be a native Java |
Output values:
| The string that resulted from the decoding operation. |
Example:
- description: Decode some string data to GZip
action: org.getopentest.actions.codecs.DecodeBase64
args:
sourceString: U29tZSBzdHJpbmcgdG8gZW5jb2Rl
$localData:
utf8Data: $output.decodedBytes
- description: Decode the UTF-8 byte into a string
action: org.getopentest.actions.codecs.DecodeUtf8
args:
sourceBytes: $localData.utf8Data
$localData:
originalString: $output.decodedString
EncodeBase64
Full name: org.getopentest.actions.codecs.EncodeBase64
Encode data to Base64.
| The full path to the file containing the data to encode. Default: |
| A byte array containing the data to encode. This has to be a native Java |
| A string to encode. The string will be converted into a Java |
| If the intention is to save the decoded data in a file on disk, this argument must point to the full path to the file. Default: |
Output values:
| The Base64 string that resulted from the encoding operation. |
Example:
- description: Encode some string to Base64
action: org.getopentest.actions.codecs.EncodeBase64
args:
sourceString: Some string to encode
$localData:
encodedString: $output.encodedString
EncodeUtf8
Full name: org.getopentest.actions.codecs.EncodeUtf8
Encodes data to UTF-8.
| A string to encode. The string will be converted into a Java |
Output values:
| A Java native |
Example:
- description: Encode some string to UTF-8
action: org.getopentest.actions.codecs.EncodeUtf8
args:
sourceString: Some string to encode
$localData:
encodedBytes: $output.encodedBytes
ExtractGzip
Full name: org.getopentest.actions.compression.ExtractGzip
Extracts the contents of a GZip package.
| The full path to the file to extract. Default: |
| A byte array to compress. This has to be a native Java |
| If the intention is to save the extracted data in a file on disk, this argument must point to the full path to the file. Default: |
Output values:
| A byte array containing the GZip-compressed bytes, as a native Java |
Example:
- description: Extract the products.xml file from a GZip package
action: org.getopentest.actions.compression.ExtractGzip
args:
sourceFile: $tempDir + "/products.gz"
$localData:
productsXml: $output.extractedBytes
Format
Full name: org.getopentest.actions.Format
Builds a string, starting from an initial template that interpolates JavaScript expressions by substituting the JavaScript expressions with their evaluated result. This is especially useful when building XML data dynamically.
| A string to use as the template. The string will can contain one or more JavaScript expressions using the syntax |
Output values:
| The string that was obtained after replacing the JavaScript expressions with the result of their evaluation. |
Example:
- description: Build XML data using interpolated JavaScript
action: org.getopentest.actions.Format
args:
template: |
<root>
<child>${"value" + " 1"}</child>
<child>${"value" + " 2"}</child>
</root>
- script: |
var actualXml = $output.text;
var expectedXml =
"<root>\n <child>value 1</child>\n <child>value 2</child>\n</root>\n";
if (actualXml != expectedXml) {
$fail("The XML data validation failed");
}
HttpRequest
Full name: org.getopentest.actions.HttpRequest
Executes an HTTP request to perform a REST API call, download a file from a web server, etc.
Arguments:
| Request URL. |
| HTTP verb (method). Valid values are: |
| HTTP headers to send with the request, as a list of key-value pairs. Default: an empty hash map. |
| HTTP request payload, as a string value. This is usually provided in the form of a YAML multi-line string using the "|" (pipe) character syntax. The $json JavaScript API is very often used to generate JSON content out of a JavaScript object syntax (see example below). |
| The HTTP status code that is expected in the response. The HttpRequest action will fail if a different status code is received. Default: |
| The content type of the payload. This value will be used as the |
| The full path to a file that the response body will be written to. This is particularly useful for downloading files. Default: |
| Boolean flag that instructs the HTTP client to ignore the web server SSL certificate. Useful when working with servers that use self-signed certificates (very common occurrence in dev and test environments). This can also be provided as a parameter in the test actor’s configuration file, so that it’s not repeated for each and every HTTP request. Default: false. |
| HTTP proxy server. Both the server name (or IP address) and port number can be specified, separated by ":" (e.g. |
| Boolean flag that determines whether the response payload should be parsed from JSON into a native JavaScript value, or returned as a JSON string. Normally, the test action will automatically detect whether the content is JSON data by looking in the |
Output values:
| HTTP response status code. |
| HTTP response headers, returned as a hash map. |
| HTTP response payload. If the response content type is |
| The time interval between sending the HTTP request and receiving the response, in milliseconds. |
Example:
- description: Create a new blog post
action: org.getopentest.actions.HttpRequest
args:
$localData:
postInfo: $output.body
url: https://jsonplaceholder.typicode.com/posts
headers:
Content-Type: application/json
verb: POST
body: |
$json(
{
id: 123,
title: "My fist post",
updated: Date.now()
}
)
- description: Validate post ID
script: |
if ($localData("postInfo").id != 123) {
$fail($format(
"We expected the post ID to be {0} but it was {1}",
123,
$localData("postInfo").id));
}
- description: Validate post title
script: |
if ($localData("postInfo").title != "My fist post") {
$fail($format(
"We expected the post title to be '{0}' but it was '{1}'",
"My fist post",
$localData("postInfo").title));
}
JdbcQuery
Full name: org.getopentest.actions.db.JdbcQuery
Executes a SQL query statement over JDBC (a statement that doesn’t modify any data). You must ensure that the required JDBC driver is available to the test actor that executes the test action. This is done by downloading the JDBC driver (typically provided by the database vendor) and copying the JAR file(s) to the user-jars
subdirectory in the test actor’s working directory. The test actor will load all JARs from the user-jars
subdirectory when it starts and the JDBC driver(s) will automatically get registered with the JDBC driver manager.
Arguments:
| The JDBC URL containing your database connection details. The JDBC driver manager will attempt to select the appropriate driver from the set of registered JDBC drivers, based on the specified JDBC URL. |
| The user name to authenticate with. |
| The password to authenticate with. |
| The SQL query statement to execute. |
Output values:
| An array of objects representing the rows retrieved from the database server, as per the specified SQL query. Each object in the array will have one property per each column that was selected in the query. |
| The number of rows returned by the query. |
Example:
- description: Find all "D*" employees in accounting
action: org.getopentest.actions.db.JdbcQuery
args:
jdbcUrl: jdbc:mysql://mysql.example.com/erp_db_schema
user: adrian
password: slybxdfrgaywnlrd
sql: |
SELECT id, name FROM Employees
WHERE department = 'ACCOUNTING'
AND name LIKE `D%`
- description: Validate the returned data rows
script: |
if ($output.rowCount != 2) {
$fail(
"We expected only two employee records to match, " +
"but we got " + $output.rowCount);
}
// Build a comma-separated list of employee names
var employeeNames = $output.rows
.map(function(employee) { return employee.name })
.join(", ");
$log("The matching employees are: " + employeeNames);
The rows
output value from the example above will look something like this (only included two columns for brevity):
[
{ "id": 184, "name": "Daniel" },
{ "id": 287, "name": "Derek" }
]
JdbcUpdate
Full name: org.getopentest.actions.db.JdbcUpdate
Executes a SQL update statement over JDBC (a statement that modifies one or more database records). You must ensure that the required JDBC driver is available to the test actor that executes the test action. This is done by downloading the JDBC driver (typically provided by the database vendor) and copying the JAR file(s) to the user-jars
subdirectory in the test actor’s working directory. The test actor will load all JARs from the user-jars
subdirectory when it starts and the JDBC driver(s) will automatically get registered with the JDBC driver manager.
Arguments:
| The JDBC URL containing your database connection details. The JDBC driver manager will attempt to select the appropriate driver from the set of registered JDBC drivers, based on the specified JDBC URL. |
| The user name to authenticate with. |
| The password to authenticate with. |
| The SQL update statement to execute. |
Output values:
| The number of rows modified by the query. |
Example:
- description: Update the bonus for employee 2
action: org.getopentest.actions.db.JdbcUpdate
args:
jdbcUrl: jdbc:mysql://mysql.example.com/erp_db_schema
user: adrian
password: slybxdfrgaywnlrd
sql: |
UPDATE Employees
SET bonus = 0.22
WHERE id = 2
- description: Verify that exactly one row was changed
script: |
if ($output.updateCount != 1) {
$fail(
"We expected exactly one row to be changed, " +
"but we changed " + $output.updateCount);
}
ReadEmailImap
Reads email messages from an IMAP server.
Arguments:
| IMAP server, by IP or DNS name |
| Port number to connect on. Default: 143. |
| The user name to authenticate with. |
| The password to authenticate with. |
| A substring to look for in the message subject. Only messages matching this filter will be retrieved. Default: |
| A regular expression that the message subject needs to match. |
| A substring to look for in the message body. |
| A regular expression that the message body needs to match. |
| The email address the message was received from. Only messages matching this filter will be retrieved. |
| Checks that the sent date of the message is after the specified date. The date has to be in the format |
| The maximum number of email messages to retrieve. Default: 1. |
| The minimum number of email messages to retrieve. Default: 1. |
Output values:
| An array of objects representing the email messages retrieved from the IMAP server, sorted by the received date in inverse chronological order (the most recent message is the first element in the array). Each object in the array will have the following properties: |
Example:
- description: Read the most recent 10 emails
action: org.getopentest.actions.ReadEmailImap
args:
server: imap.gmail.com
userName: [email protected]
password: slybxdfrgaywnlrd
subjectContains: verify email
maxResults: 10
$localData:
emails: $output.emails
- script: |
var emails = $localData("emails")
$log("We retrieved " + emails.length + " emails");
$log("The subject of the first email is " + emails[0].subject);
ReadTextFile
Reads a text file from disk and outputs its contents as a string.
Full name: org.getopentest.actions.files.ReadTextFile
Arguments:
| Full path to the text file to read from. |
| The encoding the text file is stored in. Valid values are: |
| Excludes the byte order mark characters from the file content. Default: |
Output values:
| The content of the text file, as a string. |
Example:
- description: Read the translations text file from disk
action: org.getopentest.actions.files.ReadTextFile
args:
file: $tempDir + "/translations.txt"
$localData:
translations: $output.text
- script: |
var translations = $localData("translations")
$log("The translations file content was " + translations);
ReadXml
Parses XML data from a string or from a file and outputs its contents to an object that allows access to the XML data through a friendly API.
Full name: org.getopentest.actions.ReadXml
Arguments:
| Full path to the XML file to read from. Exactly one of the |
| The XML to parse, as a string. |
Output values:
| The root node of the XML document as an object that exposes the following methods:
|
Example:
description: Log information about the book catalog in the library
actors:
- actor: ACTOR1
segments:
- segment: 1
actions:
- description: Parse the XML data
action: org.getopentest.actions.ReadXml
args:
xml: |
<?xml version="1.0"?>
<catalog library="My Library">
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain 2</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>
- description: Log the book catalog information
script: |
var catalogNode = $output.rootNode;
var books = catalogNode.nodes();
$log("Prices:");
books.forEach(function(book) {
$log($format("- {0} costs ${1}",
book.node("title").text,
book.node("price").text));
});
$log("Library name is " + catalogNode.attribute("library"));
$log("Library has a total of " + books.length + " books");
$log("The first book title is " + books[0].node("title").text);
$log("The first book ID is " + books[0].attribute("id"));
WriteTextFile
Writes a text file to disk.
Full name: org.getopentest.actions.files.WriteTextFile
Arguments:
| Full path to the text file to write to. |
| The text to write to the file. |
| The encoding that will be used to write the data to the file. Valid values are: |
| Determines what happens when the target file already exits - whether the existing file will be appended to, or completely overwritten with the value provided in the |
Example:
- description: Write some XML data to disk
action: org.getopentest.actions.files.WriteTextFile
args:
targetFile: $tempDir + "/xml-data.txt"
text: |
<?xml version="1.0"?>
<catalog library="My Library">
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain 2</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>