Generic keywords


CompressGzip

Full name: org.getopentest.actions.compression.CompressGzip

Compresses a file, a byte sequence or a string into a GZip package.

sourceFile

The full path to the file to compress. Default: null. Exactly one of the sourceFile, sourceBytes or sourceString arguments must be provided.

sourceBytes

A byte array to compress. This has to be a native Java byte[] type. Default: null.

sourceString

A string to compress. The string will be first converted into the equivalent byte array, using the UTF-8 encoding. Default: null.

targetFile

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: null.

Output values:

compressedBytes

A byte array containing the GZip-compressed bytes, as a native Java byte[]. This output value will be generated, regardless of the targetFile argument being set or not.

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.

sourceFile

The full path to the file containing the Base64 string to decode. Default: null. Exactly one of the sourceFile, sourceBytes or sourceString arguments must be provided.

sourceBytes

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 byte[] type. Default: null.

sourceString

A string to decode. Default: null.

targetFile

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: null.

Output values:

decodedBytes

A byte array containing the decoded bytes, as a native Java byte[]. This output value will be generated, regardless of the targetFile argument being set or not.

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.

sourceBytes

A byte array containing the UTF-8 data to decode. This has to be a native Java byte[] type. Default: null.

Output values:

decodedString

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.

sourceFile

The full path to the file containing the data to encode. Default: null. Exactly one of the sourceFile, sourceBytes or sourceString arguments must be provided.

sourceBytes

A byte array containing the data to encode. This has to be a native Java byte[] type. Default: null.

sourceString

A string to encode. The string will be converted into a Java byte[] using the UTF-8 encoding. Default: null.

targetFile

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: null.

Output values:

encodedString

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.

sourceString

A string to encode. The string will be converted into a Java byte[] using the UTF-8 encoding. Default: null.

Output values:

encodedBytes

A Java native byte[] containing the bytes that resulted from the encoding operation.

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.

sourceFile

The full path to the file to extract. Default: null. Exactly one of the sourceFile or sourceBytes arguments must be provided.

sourceBytes

A byte array to compress. This has to be a native Java byte[] type. Default: null.

targetFile

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: null.

Output values:

extractedBytes

A byte array containing the GZip-compressed bytes, as a native Java byte[]. This output value will be generated, regardless of the targetFile argument being set or not.

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.

template

A string to use as the template. The string will can contain one or more JavaScript expressions using the syntax ${<JS_EXPRESSION>} (e.g. 2 plus 2 is ${2+2}).

Output values:

text

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:

url

Request URL.

verb

HTTP verb (method). Valid values are: GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH). Default: GET.

headers

HTTP headers to send with the request, as a list of key-value pairs. Default: an empty hash map.

body

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).

successStatusCode

The HTTP status code that is expected in the response. The HttpRequest action will fail if a different status code is received. Default: null.

contentType

The content type of the payload. This value will be used as the Content-Type HTTP header. Alternatively, this can also be provided in the headers argument. Default: text/plain.

outputFile

The full path to a file that the response body will be written to. This is particularly useful for downloading files. Default: null.

ignoreCert

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.

proxy

HTTP proxy server. Both the server name (or IP address) and port number can be specified, separated by ":" (e.g. localhost:8888). This can also be provided as the api.httpProxy parameter in the test actor’s configuration file, so that it’s not repeated for each and every HTTP request. Default: null.

parseBody

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 Content-Type header. By setting the parseBody argument, the user can override this automatic behavior. Parsing the JSON body into a native JavaScript value is helpful if you need to use the dot syntax to access properties in the payload, which is required in most cases for response validation. Default: null.

Output values:

statusCode

HTTP response status code.

headers

HTTP response headers, returned as a hash map.

body

HTTP response payload. If the response content type is */json, the payload will automatically be parsed and returned as a JavaScript object.

durationMs

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:

jdbcUrl

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.

user

The user name to authenticate with.

password

The password to authenticate with.

sql

The SQL query statement to execute.

Output values:

rows

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.

rowCount

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:

jdbcUrl

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.

user

The user name to authenticate with.

password

The password to authenticate with.

sql

The SQL update statement to execute.

Output values:

updateCount

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:

server

IMAP server, by IP or DNS name

port

Port number to connect on. Default: 143.

userName

The user name to authenticate with.

password

The password to authenticate with.

subjectContains

A substring to look for in the message subject. Only messages matching this filter will be retrieved. Default: null.

subjectRegex

A regular expression that the message subject needs to match.

bodyContains

A substring to look for in the message body.

bodyRegex

A regular expression that the message body needs to match.

from

The email address the message was received from. Only messages matching this filter will be retrieved.

sentAfter

Checks that the sent date of the message is after the specified date. The date has to be in the format YYYY-MM-DD HH:MM:SS Only messages matching this filter will be retrieved.

maxResults

The maximum number of email messages to retrieve. Default: 1.

minResults

The minimum number of email messages to retrieve. Default: 1.

Output values:

emails

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: subject, body, from, to, sentDate, headers.

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:

sourceFile

Full path to the text file to read from.

encoding

The encoding the text file is stored in. Valid values are: US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16. Default: UTF-8.

excludeBom

Excludes the byte order mark characters from the file content. Default: true.

Output values:

text

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:

file

Full path to the XML file to read from. Exactly one of the file or xml arguments must be provided.

xml

The XML to parse, as a string.

Output values:

rootNode

The root node of the XML document as an object that exposes the following methods:

  • attribute(attributeName) Returns the value of the attribute with the specified name.

  • attributes() Returns an object (hashmap) whose properties represent the attributes of the XML element.

  • name The tag name of the XML element.

  • node(xpathExpression) Returns the very first node that matched the provided XPath expression, or null, if nothing was matched. The object returned will have the same API as the original node object that this method was called on.

  • nodes(xpathExpression) Returns an array of objects representing the nodes that matched the provided XPath expression. Each object returned will have the same API as the original node object that this method was called on. If no XPath expression is provided, the function will return all the child nodes of the node it was called on.

  • nodeType Returns the type of node as a string, which is one of the following values: attribute, cdata, comment, doctype, element, entity, entityref, notation, instruction, text.

  • prefix Returns the namespace prefix of this node, or null if it is unspecified.

  • text Returns the text content of this node and its descendants.

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:

targetFile

Full path to the text file to write to.

text

The text to write to the file.

encoding

The encoding that will be used to write the data to the file. Valid values are: US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16. Default: UTF-8.

append

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 text argument. Default: false.

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>