Class SessionEventData

java.lang.Object
org.openqa.selenium.grid.data.SessionEventData

public class SessionEventData extends Object
Data structure for user-defined session events. This allows clients to fire custom events through the Grid that sidecar services can consume.

Example use cases:

  • Notify on test failure to collect logs
  • Trigger screenshot capture at specific points
  • Mark test phases for video annotation
  • Request custom resource collection
  • Send test metadata for reporting

Event Types

Common event types include:

  • test:started - Test has begun execution
  • test:passed - Test completed successfully
  • test:failed - Test failed with error
  • test:skipped - Test was skipped
  • log:collect - Request log collection
  • screenshot:capture - Request screenshot capture
  • marker:add - Add a marker/annotation point

Wire Format (JSON)

{
  "sessionId": "abc123",
  "eventType": "test:failed",
  "nodeId": "node-uuid",
  "nodeUri": "http://node:5555",
  "timestamp": "2024-01-15T10:30:00Z",
  "payload": {
    "testName": "LoginTest",
    "error": "Element not found",
    "screenshot": true
  }
}
  • Constructor Details

  • Method Details

    • create

      public static SessionEventData create(SessionId sessionId, String eventType, Map<String,Object> payload)
      Creates a SessionEventData with just session ID and event type (for client-side creation).
      Parameters:
      sessionId - the session ID
      eventType - the type of event (e.g., "test:failed", "log:collect")
      payload - optional payload data
    • withNodeContext

      public SessionEventData withNodeContext(NodeId nodeId, URI nodeUri)
      Creates a copy of this event with node context added (used when processing on the node).
      Parameters:
      nodeId - the node ID
      nodeUri - the node URI
      Returns:
      a new SessionEventData with node context
    • getSessionId

      public SessionId getSessionId()
    • getEventType

      public String getEventType()
    • getNodeId

      public @Nullable NodeId getNodeId()
    • getNodeUri

      public @Nullable URI getNodeUri()
    • getTimestamp

      public Instant getTimestamp()
    • getPayload

      public Map<String,Object> getPayload()
    • get

      public Object get(String key)
      Gets a value from the payload.
      Parameters:
      key - the key to look up
      Returns:
      the value, or null if not present
    • getString

      public @Nullable String getString(String key)
      Gets a string value from the payload.
      Parameters:
      key - the key to look up
      Returns:
      the string value, or null if not present or not a string
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Gets a boolean value from the payload.
      Parameters:
      key - the key to look up
      defaultValue - the default value if not present
      Returns:
      the boolean value
    • toString

      public String toString()
      Overrides:
      toString in class Object