MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / subscribe

Method subscribe

java/src/org/openqa/selenium/bidi/BiDi.java:128–139  ·  view source on GitHub ↗
(Map<String, Object> params, Event<X> event, Consumer<X> handler)

Source from the content-addressed store, hash-verified

126 // later: it is unique regardless of whether the subscription was scoped to events, contexts, or
127 // user contexts, so there is no need to separately track how a listener was subscribed.
128 private <X> String subscribe(Map<String, Object> params, Event<X> event, Consumer<X> handler) {
129 return whileHoldingSubscriptionLock(() -> {
130 Map<String, Object> result = send(new Command<>("session.subscribe", params, Map.class));
131 Object subscriptionId = result.get("subscription");
132 if (!(subscriptionId instanceof String) || ((String) subscriptionId).isEmpty()) {
133 throw new BiDiException(
134 "session.subscribe did not return a valid subscription id: " + result);
135 }
136 connection.addListener((String) subscriptionId, event, handler);
137 return (String) subscriptionId;
138 });
139 }
140
141 public <X> void clearListener(Set<String> browsingContextIds, Event<X> event) {
142 Require.nonEmpty("List of browsing context ids", browsingContextIds);

Callers 1

addListenerMethod · 0.95

Calls 5

sendMethod · 0.95
getMethod · 0.65
addListenerMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected