This article lists the commands supported by the
Web Socket Test.
Catchpoint's Web Socket Test supports the following Script commands:
assertData()
Syntax:
assertData(text, format)
Description:
Works with sendData() to confirm the server responds with the expected content. If assertData() fails to find the asserted content in the server response, the test will fail.
Arguments:
| text | Required | String content or encoded string (for binary) to assert |
| format | Optional | Format of asserted text - "text" (default), "hex", or "base64". |
Example:
assertData("hello")
Open()
Syntax:
open(url)
Description:
Opens a URL to begin testing
Arguments:
| url | Required | URL to open request for |
Example:
open("http://www.catchpoint.com")
Pause()
Syntax:
pause(time)
Description
Pauses execution of the script for the specified amount of time before continuing to next step
Arguments:
| time | Required | Amount of time to wait, in milliseconds. |
Example:
pause(5000)
sendData()
Syntax:
sendData(text, format)
Description
Posts data to the opened URL
Arguments:
| text | Required | String content or encoded string (for binary) to send via WebSockets. |
| format | optional | Specifies data format. "text" or "hex" or "base64" default is "text" if not specified |
Example:
sendData("this is the data")
sendPing()
Syntax:
sendPing(waitTime)
Description
Executes the ping command to the opened URL's host.
Arguments:
| waitTime | Optional | Amount of time to wait for pong frame, in milliseconds. Default is two seconds (2000) Max is twenty seconds (20000) |
Example:
sendPing(10000)
setHeader()
Syntax:
setHeader(key,value)
Description
Allows you to override or add new HTTP headers to the request for the test or specific request.
Arguments
| key | Required | The key of the header to be added/replaced |
| value | Required | The header value to be added/replaced |
Example:
setHeader("Authorization","Bearer <token>")
setIndicator()
Syntax:
setIndicator(name, value)
Description
Saves an Insight Indicator.
Arguments
| name | Required | The name of the Insight Indicator to be saved |
| value | Required | The value to be saved for the Indicator (supports Macros) |
Example:
setIndicator("Authorization","Bearer <token>")
setStepName()
Syntax:
setStepName(name)
Description
Assigns a friendly name to a step, which can then be used as a filter, Breakdown, and Dimension in Performance Charts and Reports. The step name also replaces the URL in the Step section of the Waterfall Charts.
Arguments
| name | Required | Friendly name to associate with this step |
Example
setStepName("Open Home Page")
setTracepoint()
Syntax:
setTracepoint(name, value)
Description
Saves an Insight Tracepoint.
Arguments
| name | Required | The name of the Insight Tracepoint to be saved |
| value | Required | The value to be saved for the Tracepoint (supports Macros) |
Example
setTracepoint(${random})
storeGlobalVariable()
Syntax:
storeGlobalVariable(value,name)
Description
Saves a variable that can be used in subsequent tests.
Arguments
| value | Required | The value to assign to the global variable (supports Macros) |
| name | Required | The name of the global variable |
storeVariable()
Syntax:
storeVariable(var or extract macro, variable name)
Description
Saves a variable that can be used within this test only.
Arguments
| value | Required | The value to assign to the variable (supports Macros) |
| name | Required | The name of the variable |
Macros
Please see the following article for a reference of what macros are supported in the Websocket test: https://docs.catchpoint.com/docs/test-macros
Example Script
// Step - 1
open("wss://echo.websocket.org")
sendData(hello)
assertData(hello)