DevWeb JavaScript SDK

This section describes the various objects, methods, and properties that are part of the JavaScript SDK for DevWeb scripts.

For information on the concepts and structure used for the scripts, see Script structure.

Note: If you are manually writing a script, make sure it uses UTF-8 encoding without a BOM.

Flow control

This function group provides functions that are responsible for the flow control of the Vuser life cycle.

Back to top

WebRequest

This object enables you to send web requests to the AUT. When creating a WebRequest, you can pass an options object with all the configuration you need for the request. Then you can send the request asynchronously or synchronously.

Methods

Back to top

WebResponse

This object is returned as a WebRequest result. You do not need to create it on your own.

Properties

Methods

Back to top

WebSocket

An object that enables you to create a WebSocket connection to the AUT. When creating a WebSocket, you need to pass an options object with all the required configuration. You can then send and receive messages over the socket.

Methods

Back to top

gRPC

The gRCP APIs provide support for the native gRPC communication protocol when replaying DevWeb scripts. (gRPC-Web is not supported.)

Tip: The <DevWeb root folder>\examples\ folder includes a usage example script for gRPC.

GrpcClient

An object that creates a new client that can be used to make RPCs to a gRPC server.

Example:

const client = new load.GrpcClient({
        host: "myHost",
        isInsecure: true,
    });

Methods

GrpcUnaryRequest

Creates unary RPC request object.

Methods

GrpcClientStreamRequest

Creates a client-streaming RPC request object.

Methods

GrpcServerStreamRequest

Creates a server-streaming RPC request object.

Methods

GrpcBiDirectionalStreamRequest

Creates bidirectional streaming RPC request object.

Methods

GrpcResponse

This object is returned as a GrpcRequest result. You do not need to create it.

Back to top

Extractors

You can specify which values are extracted from the response of a specific WebRequest, the response of a specific gRPC request, or the File read method, by providing the extractors option parameter.

This parameter is an extractor object, or an array of extractor objects, that are created using the helper constructor functions described in Extractor types, below.

Extractor types

Extractor results

The results of all the extractors are merged into a single object under the extractors property on the result object. For example, when using extractors on a WebRequest, the resulting extracted values are stored on the extractors property of the WebResponse object created by that request.

The extracted values can be retrieved from the extractors property by using the extractor name. The name is specified as the first argument of the extractor object constructor.

For convenience, each extracted value is also stored on the extractors property of the load namespace, accessible anywhere in the script.

Note: If an extractor object has the same name as another extractor object, only the last extractor result is saved and a warning is printed to the log.

Each extractor object returns the results in a different format. For the particular format, see the particular extractor object definitions in Extractor types.

Back to top

Transactions

Transactions provide the means to measure the time it takes to execute specific, well-defined parts of the script.

Properties

Methods

Back to top

Parameters

Parameters are values generated during runtime by the runtime engine and are exposed to the script through the load.params variable.

Each time you use a parameter variable, the next value is loaded automatically based on the next value selection strategy in the parameters definition file.

For more information, see Parameterize values.

Back to top

General methods

Back to top

Timer

An object that enables you to create a timer that fires after a specified delay. The timer can fire once, or every time the specified delay has passed, until it is stopped.

Methods

Back to top

Rendezvous

The rendezvous function creates a rendezvous point in a DevWeb script. When this statement is executed, the Vuser stops running and waits for permission to continue.

  • This function can be used only in an action section, and not in an initialize or finalize section.
  • The name parameter (rendezvous_name) that is supplied to the rendezvous function must be without spaces.

Note: This capability is not available when executing scripts locally using LoadRunner Developer.

Example:

load.action("Action", async function () {
        load.rendezvous("rendezvous_name")
    });

Back to top

Global

Changing the properties of the load object is not permitted, but a global object is provided for you to store your data. You can access this object using the load.global property.

Example:

load.global.myData = 1;

// in another file ...

 load.log(`The value of myData is ${load.global.myData}`); 

Back to top

Config

A global configuration object that is used to supply various configuration data to the running Vuser.

Properties

Back to top

Utils

The utils object has some useful functions that may help you with common scripting tasks.

Methods

Chain

This class provides a mechanism to chain calls to other utils functions or custom functions that have one of the signatures: func(), func(value), func(value,options)

Example:

const myChain = new load.utils.Chain("base64Encode",(value)=>{ return {encoded:value};});
const myValue = myChain.run("Hello"); //myValue = {"encoded":"SGVsbG8="}

Back to top

Net

The net API provides useful network-related functionality.

Back to top

Azure

Microsoft Azure Key Vault is a cloud service used to securely store and access secrets, meaning confidential data such as passwords, certificates, or cryptographic keys. Azure API functions support access to Microsoft Azure Key Vault. For more information, see Access Azure Key Vault secrets.

Back to top

Cookies

This group of functions enable you to add, remove, or clear the cookies used in web requests.

Cookie

An object that encapsulates all the fields of a cookie.

Back to top

VTS

The VTS integration API enables you to connect to a VTS server and perform various operations on it, such as reading and writing from columns, and managing indices.

VTSClient

The VTSClient is responsible for issuing commands to the VTS server. Use it to obtain other VTS-related constructs such as VTSColumn and VTSRow.

The client enables you to perform general operations that affect more than one column or row.

Methods

VTSColumn

This refers to a column on the VTS server. Use this object to perform operations on the underlying column.

Properties

Methods

VTSRow

This refers to a row on the VTS server. Use this object to perform operations on the underlying row.

Properties

Methods

Back to top

File

An object that allows file operations on a particular file.

Methods

Back to top

SSE

Server-sent events (SSE) is a server push technology, enabling a client to receive automatic updates from a server through an HTTP connection. The SSE object enables connection to the AUT, and to receive server-sent event notifications.

When creating an SSE instance, you pass an options object with all the required configuration.

Methods

Back to top

See also: