Loadmill
Learn moreSchedule a demo
  • Introduction
    • Loadmill - AI - Powered Solution
    • Deviceless mobile testing
      • Capturing traffic with Loadmill MITM Proxy
      • Loadmill desktop recorder
        • Generating test flows
      • Installing certificate on mobile devices
        • iOS certificate installation
        • Android certificate installation
      • Configuring proxy on mobile devices
        • iOS Wi-Fi settings
        • Android Wi-Fi settings
      • Troubleshooting
    • What is an API
      • API - Data Fetching
      • Quick examples of API requests
      • What is an API endpoint?
    • API Server Testing
      • Contract testing
      • Regression Testing
  • Quick Guide
    • Create Account
    • Download Test Composer
    • Register your first API flow
    • Running Your API Test
  • Loadmill Test Composer
    • Quickstart
    • Composer Layout
    • Filter Settings
  • Test Editor
    • Layout
    • Flows
      • Generated Flow Code
      • Test Flow editor
      • Flow Controls
      • Add CSV to Flow
      • Flow Execution
    • Steps
      • Request step
      • Code step
      • Extraction & Assertion step
      • Web Socket step
    • Extractions - Set Parameters
    • Assertions - Verify Response
    • Parameters
      • Parameter Execution Order
      • Test Suite Parameters
      • Parameters Sets
    • ⨍(⨯) FUNCTIONS
    • Postscript
      • Running Postscript
      • Accessing w/ Postscript
      • Validating Postscript
    • Login/Authentication Flow
    • Before & After Hooks
  • Load Testing
    • Load Test Editor
    • Load Testing Guide
    • Analyzing Load Test Results
    • Parameterized Load Test
    • Domain Verification
    • Configuration Files
    • Load Testing FAQs
    • Load Testing Troubleshooting
  • User Behavior Testing
    • Overview
    • Setup
    • Recording troubleshooting
    • Additional recording methods
    • Recording settings
    • How to work with Recordings
  • Auth
    • Okta SSO integration
    • API Tokens
    • Testing with CORS
    • REST API
  • Integrations
    • Loadmill Agent
    • CI integration
    • GitHub
      • CI integration
      • Data sync
    • GitLab
    • Bitbucket
    • Jira
    • New Relic
    • Slack integration
    • TestRail integration
    • Database Testing
    • Kafka Testing
    • Datadog Integration
    • ✉️Email Testing
    • Webhook Testing
    • Integrations FAQs
    • XRay
    • TestRail
    • gRPC Support
  • Collaboration
    • Collaboration
    • Teams
    • Groups & Reports
    • Test Suite Collaboration
    • Reviews
    • Shared Flows
    • Labels
  • Reporting
    • API Catalog & Coverage
      • API Catalog
        • Unique Entity ID's Mapping
        • Domain Mapping and grouping
        • Endpoints grouping
        • OpenAPI upload
      • Test Coverage
        • Generating API test coverage report
  • General
    • Billing
      • Usage report
    • Settings
      • 📈Analytics
        • Flow Run History
      • 🧳Import & Export
    • General FAQs
    • General troubleshooting
    • Comparisons
      • Loadmill vs. SoapUI
      • Loadmill vs. JMeter
      • Loadmill vs. Blazemeter
      • Loadmill vs. WebdriverIO
      • Loadmill vs. Potato
    • Miscellaneous
      • Running a Test Suite
      • Test Plan
      • API Testing troubleshooting
      • API Testing FAQs
      • Test Editor
        • API Tests - Data from CSV files
Powered by GitBook
On this page
  • WebSocket Step Operations
  • Step Configuration
  • Connection
  • Sending Messages
  • Receiving Messages
  • Example Run
  1. Test Editor
  2. Steps

Web Socket step

PreviousExtraction & Assertion stepNextExtractions - Set Parameters

Last updated 2 months ago

The WebSocket step enables real-time, bidirectional communication testing by allowing you to connect to WebSocket endpoints, send messages, and validate responses. This step is particularly useful for testing applications that require persistent connections and real-time data exchange.

WebSocket Step Operations

A WebSocket step can perform three main operations:

  1. Connect - Establishes a WebSocket connection to the specified endpoint

  2. Send - Transmits messages through an established WebSocket connection

  3. Receive - Listens for and validates incoming WebSocket messages

Step Configuration

Connection

When establishing a connection:

  • The URL format follows: wss://<your-websocket-endpoint>

  • Headers can be added to the WebSocket handshake request for authentication or custom protocols

  • A timeout value (in seconds) can be set for the connection attempt

Sending Messages

For sending messages:

  • Supports two data types:

    • Text (JSON, plain text)

    • Binary data

  • Messages can include dynamic parameters

  • Headers can be included with the message

  • Used for both sending data and subscribing to channels

  • A timeout can be specified for the send operation

Note: A Send step without a preceding Connect step will automatically create a new WebSocket connection.

Receiving Messages

When receiving messages:

  • Messages are fetched based on the WebSocket URL

    • Use URL query parameters (e.g., wss://example.com/ws?userId=1) to send and filter messages by specific properties

  • Message retrieval options:

    • Last - Returns the most recent single message

    • Last 10 - Returns an array of the last 10 messages

    • Last 50 - Returns an array of the last 50 messages

  • Extractions support all standard Loadmill extraction methods

    • Example JSONPath for array filtering: $[?(@.id == "${my_id}")]

  • Wait for extractions to be resolved - Since WebSocket connections are asynchronous, this setting defines how long to wait for messages that match your extraction criteria. Default is 5 seconds, but you may need to adjust this based on your application's behavior.

  • The Flow Control section allows to repeat the request until the parameter's value meets the requirement or number of iteration reached.

Example Run

Let's look at a simple WebSocket test flow in action:

This example demonstrates a complete WebSocket interaction:

1. Connect to WebSocket:

  • Establishes connection to a WebSocket server

2. Send Some Data:

  • Sends a message on the connection

3. Assert message received:

  • Waits for all extractions to be resolved

  • Once resolved, validates that the extracted ${message} exists

  • Received messages are displayed for easy debugging

Assertions - Use the same powerful assertion capabilities as HTTP requests to validate your WebSocket messages, including JSON/XML validation, value comparisons, and regex matching.

Learn more about extractions
Learn more about assertions