Class SessionEventData
java.lang.Object
org.openqa.selenium.grid.data.SessionEventData
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 executiontest:passed- Test completed successfullytest:failed- Test failed with errortest:skipped- Test was skippedlog:collect- Request log collectionscreenshot:capture- Request screenshot capturemarker: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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SessionEventDataCreates a SessionEventData with just session ID and event type (for client-side creation).Gets a value from the payload.booleangetBoolean(String key, boolean defaultValue) Gets a boolean value from the payload.@Nullable NodeId@Nullable URI@Nullable StringGets a string value from the payload.toString()withNodeContext(NodeId nodeId, URI nodeUri) Creates a copy of this event with node context added (used when processing on the node).
-
Constructor Details
-
SessionEventData
-
-
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 IDeventType- the type of event (e.g., "test:failed", "log:collect")payload- optional payload data
-
withNodeContext
Creates a copy of this event with node context added (used when processing on the node).- Parameters:
nodeId- the node IDnodeUri- the node URI- Returns:
- a new SessionEventData with node context
-
getSessionId
-
getEventType
-
getNodeId
-
getNodeUri
-
getTimestamp
-
getPayload
-
get
-
getString
-
getBoolean
Gets a boolean value from the payload.- Parameters:
key- the key to look updefaultValue- the default value if not present- Returns:
- the boolean value
-
toString
-