diff --git a/java/server/src/org/openqa/selenium/grid/data/CreateSessionRequest.java b/java/server/src/org/openqa/selenium/grid/data/CreateSessionRequest.java index 57a3fac93c6f8..2eaacf6523b33 100644 --- a/java/server/src/org/openqa/selenium/grid/data/CreateSessionRequest.java +++ b/java/server/src/org/openqa/selenium/grid/data/CreateSessionRequest.java @@ -53,7 +53,7 @@ public Set getDownstreamDialects() { return downstreamDialects; } - public Capabilities getCapabilities() { + public Capabilities getDesiredCapabilities() { return capabilities; } @@ -69,7 +69,7 @@ private static CreateSessionRequest fromJson(JsonInput input) { input.beginObject(); while (input.hasNext()) { switch (input.nextName()) { - case "capabilities": + case "desiredCapabilities": capabilities = input.read(Capabilities.class); break; diff --git a/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java b/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java index 6747300d855e5..83c873750c337 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java +++ b/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java @@ -195,7 +195,7 @@ public Either newSession(Sess // Reject new session immediately if no node has the required capabilities boolean hostsWithCaps = model.stream() - .anyMatch(nodeStatus -> nodeStatus.hasCapability(firstRequest.getCapabilities())); + .anyMatch(nodeStatus -> nodeStatus.hasCapability(firstRequest.getDesiredCapabilities())); if (!hostsWithCaps) { String errorMessage = String.format( @@ -214,7 +214,7 @@ public Either newSession(Sess } // Find a Node that supports the capabilities present in the new session - Set slotIds = slotSelector.selectSlot(firstRequest.getCapabilities(), model); + Set slotIds = slotSelector.selectSlot(firstRequest.getDesiredCapabilities(), model); if (!slotIds.isEmpty()) { selected = reserve(slotIds.iterator().next(), firstRequest); } else { diff --git a/java/server/src/org/openqa/selenium/grid/docker/DockerSessionFactory.java b/java/server/src/org/openqa/selenium/grid/docker/DockerSessionFactory.java index 969c4371a4c3e..c24d0d19ab7db 100644 --- a/java/server/src/org/openqa/selenium/grid/docker/DockerSessionFactory.java +++ b/java/server/src/org/openqa/selenium/grid/docker/DockerSessionFactory.java @@ -133,7 +133,7 @@ public boolean test(Capabilities capabilities) { @Override public Either apply(CreateSessionRequest sessionRequest) { - LOG.info("Starting session for " + sessionRequest.getCapabilities()); + LOG.info("Starting session for " + sessionRequest.getDesiredCapabilities()); int port = runningInDocker ? 4444 : PortProber.findFreePort(); try (Span span = tracer.getCurrentContext().createSpan("docker_session_factory.apply")) { @@ -143,7 +143,7 @@ public Either apply(CreateSessionRequest sess String logMessage = runningInDocker ? "Creating container..." : "Creating container, mapping container port 4444 to " + port; LOG.info(logMessage); - Container container = createBrowserContainer(port, sessionRequest.getCapabilities()); + Container container = createBrowserContainer(port, sessionRequest.getDesiredCapabilities()); container.start(); ContainerInfo containerInfo = container.inspect(); @@ -184,7 +184,7 @@ public Either apply(CreateSessionRequest sess Command command = new Command( null, - DriverCommand.NEW_SESSION(sessionRequest.getCapabilities())); + DriverCommand.NEW_SESSION(sessionRequest.getDesiredCapabilities())); ProtocolHandshake.Result result; Response response; try { @@ -211,7 +211,7 @@ public Either apply(CreateSessionRequest sess SessionId id = new SessionId(response.getSessionId()); Capabilities capabilities = new ImmutableCapabilities((Map) response.getValue()); - Capabilities mergedCapabilities = capabilities.merge(sessionRequest.getCapabilities()); + Capabilities mergedCapabilities = capabilities.merge(sessionRequest.getDesiredCapabilities()); Container videoContainer = null; Optional path = ofNullable(this.assetsPath); diff --git a/java/server/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java b/java/server/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java index 61ca01d8ebc3b..91b308b6389bc 100644 --- a/java/server/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java +++ b/java/server/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java @@ -94,14 +94,14 @@ public Either apply(CreateSessionRequest sess return Either.left(new SessionNotCreatedException("No downstream dialects were found.")); } - if (!test(sessionRequest.getCapabilities())) { + if (!test(sessionRequest.getDesiredCapabilities())) { return Either.left(new SessionNotCreatedException("New session request capabilities do not " + "match the stereotype.")); } try (Span span = tracer.getCurrentContext().createSpan("driver_service_factory.apply")) { - Capabilities capabilities = browserOptionsMutator.apply(sessionRequest.getCapabilities()); + Capabilities capabilities = browserOptionsMutator.apply(sessionRequest.getDesiredCapabilities()); Optional platformName = Optional.ofNullable(capabilities.getPlatformName()); if (platformName.isPresent()) { diff --git a/java/server/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java b/java/server/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java index 16dceabd6e07b..5ac9104defa54 100644 --- a/java/server/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java +++ b/java/server/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java @@ -163,7 +163,7 @@ public Either newSession(CreateSessio throw new IllegalStateException("Only expected one session at a time"); } - Optional driver = driverInfo.createDriver(sessionRequest.getCapabilities()); + Optional driver = driverInfo.createDriver(sessionRequest.getDesiredCapabilities()); if (!driver.isPresent()) { return Either.left(new WebDriverException("Unable to create a driver instance")); } diff --git a/java/server/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/server/src/org/openqa/selenium/grid/node/local/LocalNode.java index 23a8b539251e4..93e4895273381 100644 --- a/java/server/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/server/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -279,7 +279,7 @@ public Either newSession(CreateSessio attributeMap .put(AttributeKey.LOGGER_CLASS.getKey(), EventAttribute.setValue(getClass().getName())); attributeMap.put("session.request.capabilities", - EventAttribute.setValue(sessionRequest.getCapabilities().toString())); + EventAttribute.setValue(sessionRequest.getDesiredCapabilities().toString())); attributeMap.put("session.request.downstreamdialect", EventAttribute.setValue(sessionRequest.getDownstreamDialects().toString())); @@ -304,7 +304,7 @@ public Either newSession(CreateSessio SessionSlot slotToUse = null; synchronized (factories) { for (SessionSlot factory : factories) { - if (!factory.isAvailable() || !factory.test(sessionRequest.getCapabilities())) { + if (!factory.isAvailable() || !factory.test(sessionRequest.getDesiredCapabilities())) { continue; } diff --git a/java/server/src/org/openqa/selenium/grid/node/local/SessionSlot.java b/java/server/src/org/openqa/selenium/grid/node/local/SessionSlot.java index 7df04cf547c77..2c81277c59f4f 100644 --- a/java/server/src/org/openqa/selenium/grid/node/local/SessionSlot.java +++ b/java/server/src/org/openqa/selenium/grid/node/local/SessionSlot.java @@ -134,7 +134,7 @@ public Either apply(CreateSessionRequest sess return Either.left(new RetrySessionRequestException("Slot is busy. Try another slot.")); } - if (!test(sessionRequest.getCapabilities())) { + if (!test(sessionRequest.getDesiredCapabilities())) { return Either.left(new SessionNotCreatedException("New session request capabilities do not " + "match the stereotype.")); } diff --git a/java/server/src/org/openqa/selenium/grid/session/remote/ServicedSession.java b/java/server/src/org/openqa/selenium/grid/session/remote/ServicedSession.java index 61e1108554855..c0a262803ee88 100644 --- a/java/server/src/org/openqa/selenium/grid/session/remote/ServicedSession.java +++ b/java/server/src/org/openqa/selenium/grid/session/remote/ServicedSession.java @@ -154,7 +154,7 @@ public boolean test(Capabilities capabilities) { @Override public Optional apply(CreateSessionRequest sessionRequest) { Require.nonNull("Session creation request", sessionRequest); - DriverService service = createService.apply(sessionRequest.getCapabilities()); + DriverService service = createService.apply(sessionRequest.getDesiredCapabilities()); try { service.start(); @@ -168,7 +168,7 @@ public Optional apply(CreateSessionRequest sessionRequest) { service, url, sessionRequest.getDownstreamDialects(), - sessionRequest.getCapabilities()); + sessionRequest.getDesiredCapabilities()); } catch (IOException | IllegalStateException | NullPointerException | InvalidArgumentException e) { LOG.log(Level.INFO, e.getMessage(), e); service.stop(); diff --git a/java/server/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java b/java/server/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java index 307f499ee2fee..3c4b145263025 100644 --- a/java/server/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java +++ b/java/server/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java @@ -170,9 +170,9 @@ public boolean test(Capabilities capabilities) { @Override public Optional apply(CreateSessionRequest sessionRequest) { - LOG.finest("Capabilities are: " + new Json().toJson(sessionRequest.getCapabilities())); + LOG.finest("Capabilities are: " + new Json().toJson(sessionRequest.getDesiredCapabilities())); return factories.stream() - .filter(factory -> factory.test(sessionRequest.getCapabilities())) + .filter(factory -> factory.test(sessionRequest.getDesiredCapabilities())) .peek(factory -> LOG.finest(String.format("Matched factory %s", factory))) .map(factory -> factory.apply(sessionRequest)) .filter(Optional::isPresent) diff --git a/java/server/src/org/openqa/selenium/remote/server/InMemorySession.java b/java/server/src/org/openqa/selenium/remote/server/InMemorySession.java index 465919e29f280..df9bc43de7ac5 100644 --- a/java/server/src/org/openqa/selenium/remote/server/InMemorySession.java +++ b/java/server/src/org/openqa/selenium/remote/server/InMemorySession.java @@ -141,11 +141,11 @@ public Optional apply(CreateSessionRequest sessionRequest) { // Assume the blob fits in the available memory. try { - if (!provider.canCreateDriverInstanceFor(sessionRequest.getCapabilities())) { + if (!provider.canCreateDriverInstanceFor(sessionRequest.getDesiredCapabilities())) { return Optional.empty(); } - WebDriver driver = provider.newInstance(sessionRequest.getCapabilities()); + WebDriver driver = provider.newInstance(sessionRequest.getDesiredCapabilities()); // Prefer the OSS dialect. Set downstreamDialects = sessionRequest.getDownstreamDialects(); @@ -153,7 +153,7 @@ public Optional apply(CreateSessionRequest sessionRequest) { Dialect.OSS : downstreamDialects.iterator().next(); return Optional.of( - new InMemorySession(driver, sessionRequest.getCapabilities(), downstream)); + new InMemorySession(driver, sessionRequest.getDesiredCapabilities(), downstream)); } catch (IllegalStateException e) { return Optional.empty(); } diff --git a/java/server/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java b/java/server/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java index c32bde01b7394..8ccbd46532fc3 100644 --- a/java/server/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java +++ b/java/server/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java @@ -305,7 +305,7 @@ public Either newSession(CreateSessio if (running != null) { return Either.left(new SessionNotCreatedException("Session already exists")); } - Session session = factory.apply(sessionRequest.getCapabilities()); + Session session = factory.apply(sessionRequest.getDesiredCapabilities()); running = session; return Either.right( new CreateSessionResponse( diff --git a/java/server/test/org/openqa/selenium/grid/testing/TestSessionFactory.java b/java/server/test/org/openqa/selenium/grid/testing/TestSessionFactory.java index 3cebeb5ec2d83..d8b0d40f1cbff 100644 --- a/java/server/test/org/openqa/selenium/grid/testing/TestSessionFactory.java +++ b/java/server/test/org/openqa/selenium/grid/testing/TestSessionFactory.java @@ -60,7 +60,7 @@ public TestSessionFactory(Capabilities stereotype, BiFunction apply(CreateSessionRequest sessionRequest) { SessionId id = new SessionId(UUID.randomUUID()); - Session session = sessionGenerator.apply(id, sessionRequest.getCapabilities()); + Session session = sessionGenerator.apply(id, sessionRequest.getDesiredCapabilities()); URL url; try {