diff --git a/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java b/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java index d7aa7eec721fe..ac407f3933bad 100644 --- a/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java @@ -373,13 +373,21 @@ private Map getVideoContainerEnvVars( // Capabilities set to env vars with higher precedence setCapsToEnvVars(sessionRequestCapabilities, envVars); envVars.put("DISPLAY_CONTAINER_NAME", containerIp); - Optional testName = ofNullable(getTestName(sessionRequestCapabilities)); - testName.ifPresent(name -> envVars.put("SE_VIDEO_FILE_NAME", String.format("%s.mp4", name))); + Optional videoName = + ofNullable(getVideoFileName(sessionRequestCapabilities, "se:videoName")); + if (videoName.isPresent()) { + envVars.put("SE_VIDEO_FILE_NAME", String.format("%s.mp4", videoName.get())); + } else { + Optional testName = + ofNullable(getVideoFileName(sessionRequestCapabilities, "se:name")); + testName.ifPresent(name -> envVars.put("SE_VIDEO_FILE_NAME", String.format("%s.mp4", name))); + } return envVars; } - private String getTestName(Capabilities sessionRequestCapabilities) { - Optional testName = ofNullable(sessionRequestCapabilities.getCapability("se:name")); + private String getVideoFileName(Capabilities sessionRequestCapabilities, String capabilityName) { + Optional testName = + ofNullable(sessionRequestCapabilities.getCapability(capabilityName)); if (testName.isPresent()) { String name = testName.get().toString(); if (!name.isEmpty()) {