|
17 | 17 |
|
18 | 18 | package org.openqa.selenium.grid.node.local;
|
19 | 19 |
|
| 20 | +import static com.google.common.collect.ImmutableSet.toImmutableSet; |
| 21 | +import static org.openqa.selenium.grid.data.Availability.DRAINING; |
| 22 | +import static org.openqa.selenium.grid.data.Availability.UP; |
| 23 | +import static org.openqa.selenium.grid.node.CapabilityResponseEncoder.getEncoder; |
| 24 | +import static org.openqa.selenium.remote.HttpSessionId.getSessionId; |
| 25 | +import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES; |
| 26 | +import static org.openqa.selenium.remote.RemoteTags.SESSION_ID; |
| 27 | +import static org.openqa.selenium.remote.http.Contents.asJson; |
| 28 | +import static org.openqa.selenium.remote.http.Contents.string; |
| 29 | +import static org.openqa.selenium.remote.http.HttpMethod.DELETE; |
| 30 | + |
20 | 31 | import com.google.common.annotations.VisibleForTesting;
|
21 | 32 | import com.google.common.base.Ticker;
|
22 | 33 | import com.google.common.cache.Cache;
|
|
45 | 56 | import org.openqa.selenium.grid.data.SessionClosedEvent;
|
46 | 57 | import org.openqa.selenium.grid.data.Slot;
|
47 | 58 | import org.openqa.selenium.grid.data.SlotId;
|
| 59 | +import org.openqa.selenium.grid.docker.DockerSession; |
48 | 60 | import org.openqa.selenium.grid.jmx.JMXHelper;
|
49 | 61 | import org.openqa.selenium.grid.jmx.ManagedAttribute;
|
50 | 62 | import org.openqa.selenium.grid.jmx.ManagedService;
|
|
87 | 99 | import java.util.logging.Logger;
|
88 | 100 | import java.util.stream.Collectors;
|
89 | 101 |
|
90 |
| -import static com.google.common.collect.ImmutableSet.toImmutableSet; |
91 |
| -import static org.openqa.selenium.grid.data.Availability.DRAINING; |
92 |
| -import static org.openqa.selenium.grid.data.Availability.UP; |
93 |
| -import static org.openqa.selenium.grid.node.CapabilityResponseEncoder.getEncoder; |
94 |
| -import static org.openqa.selenium.remote.HttpSessionId.getSessionId; |
95 |
| -import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES; |
96 |
| -import static org.openqa.selenium.remote.RemoteTags.SESSION_ID; |
97 |
| -import static org.openqa.selenium.remote.http.Contents.asJson; |
98 |
| -import static org.openqa.selenium.remote.http.Contents.string; |
99 |
| -import static org.openqa.selenium.remote.http.HttpMethod.DELETE; |
100 |
| - |
101 | 102 | @ManagedService(objectName = "org.seleniumhq.grid:type=Node,name=LocalNode",
|
102 | 103 | description = "Node running the webdriver sessions.")
|
103 | 104 | public class LocalNode extends Node {
|
@@ -391,6 +392,14 @@ public HttpResponse executeWebDriverCommand(HttpRequest req) {
|
391 | 392 |
|
392 | 393 | @Override
|
393 | 394 | public HttpResponse uploadFile(HttpRequest req, SessionId id) {
|
| 395 | + |
| 396 | + // When the session is running in a Docker container, the upload file command |
| 397 | + // needs to be forwarded to the container as well. |
| 398 | + SessionSlot slot = currentSessions.getIfPresent(id); |
| 399 | + if (slot != null && slot.getSession() instanceof DockerSession) { |
| 400 | + return executeWebDriverCommand(req); |
| 401 | + } |
| 402 | + |
394 | 403 | Map<String, Object> incoming = JSON.toType(string(req), Json.MAP_TYPE);
|
395 | 404 |
|
396 | 405 | File tempDir;
|
|
0 commit comments