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

Method send

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

Source from the content-addressed store, hash-verified

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