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

Method send

java/src/org/openqa/selenium/bidi/Connection.java:114–159  ·  view source on GitHub ↗
(Command<X> command)

Source from the content-addressed store, hash-verified

112 }
113
114 public <X> CompletableFuture<@Nullable X> send(Command<X> command) {
115 long id = NEXT_ID.getAndIncrement();
116
117 CompletableFuture<@Nullable X> result = new CompletableFuture<>();
118 if (command.getSendsResponse()) {
119 methodCallbacks.put(
120 id,
121 NamedConsumer.of(
122 command.getMethod(),
123 inputOrException -> {
124 if (inputOrException.isRight()) {
125 try {
126 X value = command.getMapper().apply(inputOrException.right());
127 result.complete(value);
128 } catch (Exception e) {
129 LOG.log(
130 Level.WARNING,
131 String.format("Unable to map result for %s", command.getMethod()),
132 e);
133 result.completeExceptionally(e);
134 }
135 } else {
136 result.completeExceptionally(inputOrException.left());
137 }
138 }));
139 }
140
141 Map<String, Object> serialized =
142 Map.of(
143 "id", id,
144 "method", command.getMethod(),
145 "params", command.getParams());
146
147 StringBuilder json = new StringBuilder();
148 try (JsonOutput out = JSON.newOutput(json).writeClassName(false)) {
149 out.write(serialized);
150 }
151 LOG.log(getDebugLogLevel(), "-> {0}", json);
152 socket.sendText(json);
153
154 if (!command.getSendsResponse()) {
155 result.complete(null);
156 }
157
158 return result;
159 }
160
161 public <X> X sendAndWait(Command<X> command, Duration timeout) {
162 try {

Callers 2

sendAndWaitMethod · 0.95
clearListenersMethod · 0.95

Calls 15

ofMethod · 0.95
rightMethod · 0.80
leftMethod · 0.80
writeClassNameMethod · 0.80
newOutputMethod · 0.80
getDebugLogLevelMethod · 0.80
sendTextMethod · 0.80
putMethod · 0.65
getMapperMethod · 0.65
logMethod · 0.65
getSendsResponseMethod · 0.45
getMethodMethod · 0.45

Tested by

no test coverage detected