How to use ContainerConfig class of org.openqa.selenium.docker package

Best Selenium code snippet using org.openqa.selenium.docker.ContainerConfig

Source:SauceDockerSessionFactory.java Github

copy

Full Screen

...3import static com.saucelabs.grid.Common.SAUCE_OPTIONS;4import static com.saucelabs.grid.Common.getSauceCapability;5import static java.util.Optional.ofNullable;6import static org.openqa.selenium.ImmutableCapabilities.copyOf;7import static org.openqa.selenium.docker.ContainerConfig.image;8import static org.openqa.selenium.remote.Dialect.W3C;9import static org.openqa.selenium.remote.http.Contents.string;10import static org.openqa.selenium.remote.http.HttpMethod.GET;11import static org.openqa.selenium.remote.http.HttpMethod.POST;12import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;13import org.openqa.selenium.Capabilities;14import org.openqa.selenium.Dimension;15import org.openqa.selenium.ImmutableCapabilities;16import org.openqa.selenium.PersistentCapabilities;17import org.openqa.selenium.RetrySessionRequestException;18import org.openqa.selenium.SessionNotCreatedException;19import org.openqa.selenium.TimeoutException;20import org.openqa.selenium.UsernameAndPassword;21import org.openqa.selenium.WebDriverException;22import org.openqa.selenium.docker.Container;23import org.openqa.selenium.docker.ContainerConfig;24import org.openqa.selenium.docker.ContainerInfo;25import org.openqa.selenium.docker.Docker;26import org.openqa.selenium.docker.Image;27import org.openqa.selenium.docker.Port;28import org.openqa.selenium.grid.data.CreateSessionRequest;29import org.openqa.selenium.grid.node.ActiveSession;30import org.openqa.selenium.grid.node.SessionFactory;31import org.openqa.selenium.grid.node.docker.DockerAssetsPath;32import org.openqa.selenium.internal.Either;33import org.openqa.selenium.internal.Require;34import org.openqa.selenium.net.PortProber;35import org.openqa.selenium.remote.Command;36import org.openqa.selenium.remote.Dialect;37import org.openqa.selenium.remote.DriverCommand;38import org.openqa.selenium.remote.ProtocolHandshake;39import org.openqa.selenium.remote.Response;40import org.openqa.selenium.remote.SessionId;41import org.openqa.selenium.remote.http.HttpClient;42import org.openqa.selenium.remote.http.HttpRequest;43import org.openqa.selenium.remote.http.HttpResponse;44import org.openqa.selenium.remote.tracing.AttributeKey;45import org.openqa.selenium.remote.tracing.EventAttribute;46import org.openqa.selenium.remote.tracing.EventAttributeValue;47import org.openqa.selenium.remote.tracing.Span;48import org.openqa.selenium.remote.tracing.Status;49import org.openqa.selenium.remote.tracing.Tracer;50import org.openqa.selenium.support.ui.FluentWait;51import org.openqa.selenium.support.ui.Wait;52import java.io.IOException;53import java.io.UncheckedIOException;54import java.net.MalformedURLException;55import java.net.URI;56import java.net.URL;57import java.nio.charset.Charset;58import java.nio.file.Files;59import java.nio.file.Paths;60import java.time.Duration;61import java.time.Instant;62import java.util.Arrays;63import java.util.Collections;64import java.util.HashMap;65import java.util.Map;66import java.util.Objects;67import java.util.Optional;68import java.util.TimeZone;69import java.util.TreeMap;70import java.util.logging.Level;71import java.util.logging.Logger;72public class SauceDockerSessionFactory implements SessionFactory {73 private static final Logger LOG = Logger.getLogger(SauceDockerSessionFactory.class.getName());74 private final Tracer tracer;75 private final HttpClient.Factory clientFactory;76 private final Docker docker;77 private final URI dockerUri;78 private final Image browserImage;79 private final Capabilities stereotype;80 private final Image videoImage;81 private final Image assetsUploaderImage;82 private final DockerAssetsPath assetsPath;83 private final String networkName;84 private final boolean runningInDocker;85 public SauceDockerSessionFactory(86 Tracer tracer,87 HttpClient.Factory clientFactory,88 Docker docker,89 URI dockerUri,90 Image browserImage,91 Capabilities stereotype,92 Image videoImage,93 Image assetsUploaderImage,94 DockerAssetsPath assetsPath,95 String networkName,96 boolean runningInDocker) {97 this.tracer = Require.nonNull("Tracer", tracer);98 this.clientFactory = Require.nonNull("HTTP client", clientFactory);99 this.docker = Require.nonNull("Docker command", docker);100 this.dockerUri = Require.nonNull("Docker URI", dockerUri);101 this.browserImage = Require.nonNull("Docker browser image", browserImage);102 this.networkName = Require.nonNull("Docker network name", networkName);103 this.stereotype = copyOf(Require.nonNull("Stereotype", stereotype));104 this.videoImage = videoImage;105 this.assetsUploaderImage = assetsUploaderImage;106 this.assetsPath = assetsPath;107 this.runningInDocker = runningInDocker;108 }109 @Override110 public boolean test(Capabilities capabilities) {111 return stereotype.getCapabilityNames().stream()112 .map(113 name ->114 Objects.equals(stereotype.getCapability(name), capabilities.getCapability(name)))115 .reduce(Boolean::logicalAnd)116 .orElse(false);117 }118 @Override119 public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sessionRequest) {120 Optional<Object> accessKey =121 getSauceCapability(sessionRequest.getDesiredCapabilities(), "accessKey");122 Optional<Object> userName =123 getSauceCapability(sessionRequest.getDesiredCapabilities(), "username");124 if (!accessKey.isPresent() && !userName.isPresent()) {125 String message = String.format("Unable to create session. No Sauce Labs accessKey and "126 + "username were found in the '%s' block.", SAUCE_OPTIONS);127 LOG.log(Level.WARNING, message);128 return Either.left(new SessionNotCreatedException(message));129 }130 @SuppressWarnings("OptionalGetWithoutIsPresent")131 UsernameAndPassword usernameAndPassword =132 new UsernameAndPassword(userName.get().toString(), accessKey.get().toString());133 Optional<Object> dc =134 getSauceCapability(sessionRequest.getDesiredCapabilities(), "dataCenter");135 DataCenter dataCenter = DataCenter.US_WEST;136 if (dc.isPresent()) {137 dataCenter = DataCenter.fromString(String.valueOf(dc.get()));138 }139 Capabilities sessionReqCaps = removeSauceKey(sessionRequest.getDesiredCapabilities());140 LOG.info("Starting session for " + sessionReqCaps);141 int port = runningInDocker ? 4444 : PortProber.findFreePort();142 try (Span span = tracer.getCurrentContext().createSpan("docker_session_factory.apply")) {143 Map<String, EventAttributeValue> attributeMap = new HashMap<>();144 attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(),145 EventAttribute.setValue(this.getClass().getName()));146 String logMessage = runningInDocker ? "Creating container..." :147 "Creating container, mapping container port 4444 to " + port;148 LOG.info(logMessage);149 Container container = createBrowserContainer(port, sessionReqCaps);150 container.start();151 ContainerInfo containerInfo = container.inspect();152 String containerIp = containerInfo.getIp();153 URL remoteAddress = getUrl(port, containerIp);154 HttpClient client = clientFactory.createClient(remoteAddress);155 attributeMap.put("docker.browser.image", EventAttribute.setValue(browserImage.toString()));156 attributeMap.put("container.port", EventAttribute.setValue(port));157 attributeMap.put("container.id", EventAttribute.setValue(container.getId().toString()));158 attributeMap.put("container.ip", EventAttribute.setValue(containerInfo.getIp()));159 attributeMap.put("docker.server.url", EventAttribute.setValue(remoteAddress.toString()));160 LOG.info(161 String.format("Waiting for server to start (container id: %s, url %s)",162 container.getId(),163 remoteAddress));164 try {165 waitForServerToStart(client, Duration.ofMinutes(1));166 } catch (TimeoutException e) {167 span.setAttribute("error", true);168 span.setStatus(Status.CANCELLED);169 EXCEPTION.accept(attributeMap, e);170 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),171 EventAttribute.setValue(172 "Unable to connect to docker server. Stopping container: " +173 e.getMessage()));174 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);175 container.stop(Duration.ofMinutes(1));176 String message = String.format(177 "Unable to connect to docker server (container id: %s)", container.getId());178 LOG.warning(message);179 return Either.left(new RetrySessionRequestException(message));180 }181 LOG.info(String.format("Server is ready (container id: %s)", container.getId()));182 Command command = new Command(183 null,184 DriverCommand.NEW_SESSION(sessionReqCaps));185 ProtocolHandshake.Result result;186 Response response;187 try {188 result = new ProtocolHandshake().createSession(client, command);189 response = result.createResponse();190 attributeMap.put(191 AttributeKey.DRIVER_RESPONSE.getKey(),192 EventAttribute.setValue(response.toString()));193 } catch (IOException | RuntimeException e) {194 span.setAttribute("error", true);195 span.setStatus(Status.CANCELLED);196 EXCEPTION.accept(attributeMap, e);197 attributeMap.put(198 AttributeKey.EXCEPTION_MESSAGE.getKey(),199 EventAttribute200 .setValue("Unable to create session. Stopping and container: " + e.getMessage()));201 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);202 container.stop(Duration.ofMinutes(1));203 String message = "Unable to create session: " + e.getMessage();204 LOG.log(Level.WARNING, message);205 return Either.left(new SessionNotCreatedException(message));206 }207 SessionId id = new SessionId(response.getSessionId());208 Capabilities capabilities = new ImmutableCapabilities((Map<?, ?>) response.getValue());209 Capabilities mergedCapabilities = capabilities.merge(sessionReqCaps);210 Container videoContainer = null;211 Optional<DockerAssetsPath> path = ofNullable(this.assetsPath);212 if (path.isPresent()) {213 // Seems we can store session assets214 String containerPath = path.get().getContainerPath(id);215 saveSessionCapabilities(mergedCapabilities, containerPath);216 String hostPath = path.get().getHostPath(id);217 videoContainer = startVideoContainer(mergedCapabilities, containerInfo.getIp(), hostPath);218 }219 Instant startTime = Instant.now();220 Instant videoStartTime = Instant.now();221 Dialect downstream = sessionRequest.getDownstreamDialects().contains(result.getDialect()) ?222 result.getDialect() :223 W3C;224 attributeMap.put(225 AttributeKey.DOWNSTREAM_DIALECT.getKey(),226 EventAttribute.setValue(downstream.toString()));227 attributeMap.put(228 AttributeKey.DRIVER_RESPONSE.getKey(),229 EventAttribute.setValue(response.toString()));230 SauceCommandInfo commandInfo = new SauceCommandInfo.Builder()231 .setStartTime(startTime.toEpochMilli())232 .setVideoStartTime(videoStartTime.toEpochMilli())233 .setEndTime(Instant.now().toEpochMilli())234 .setRequest(sessionReqCaps)235 .setResult(mergedCapabilities)236 .setPath("/session")237 .setHttpStatus(response.getStatus())238 .setHttpMethod(POST.name())239 .setStatusCode(0)240 .setScreenshotId(-1)241 .build();242 span.addEvent("Docker driver service created session", attributeMap);243 LOG.fine(String.format(244 "Created session: %s - %s (container id: %s)",245 id,246 capabilities,247 container.getId()));248 return Either.right(new SauceDockerSession(249 container,250 videoContainer,251 tracer,252 client,253 id,254 remoteAddress,255 stereotype,256 mergedCapabilities,257 downstream,258 result.getDialect(),259 startTime,260 assetsPath,261 usernameAndPassword,262 dataCenter,263 assetsUploaderImage,264 commandInfo,265 docker));266 }267 }268 private Container createBrowserContainer(int port, Capabilities sessionCapabilities) {269 Map<String, String> browserContainerEnvVars = getBrowserContainerEnvVars(sessionCapabilities);270 long browserContainerShmMemorySize = 2147483648L; //2GB271 ContainerConfig containerConfig = image(browserImage)272 .env(browserContainerEnvVars)273 .shmMemorySize(browserContainerShmMemorySize)274 .network(networkName);275 if (!runningInDocker) {276 containerConfig = containerConfig.map(Port.tcp(4444), Port.tcp(port));277 }278 return docker.create(containerConfig);279 }280 private Map<String, String> getBrowserContainerEnvVars(Capabilities sessionRequestCapabilities) {281 Optional<Dimension> screenResolution =282 ofNullable(getScreenResolution(sessionRequestCapabilities));283 Map<String, String> envVars = new HashMap<>();284 if (screenResolution.isPresent()) {285 envVars.put("SCREEN_WIDTH", String.valueOf(screenResolution.get().getWidth()));286 envVars.put("SCREEN_HEIGHT", String.valueOf(screenResolution.get().getHeight()));287 }288 Optional<TimeZone> timeZone = ofNullable(getTimeZone(sessionRequestCapabilities));289 timeZone.ifPresent(zone -> envVars.put("TZ", zone.getID()));290 return envVars;291 }292 private Container startVideoContainer(Capabilities sessionCapabilities,293 String browserContainerIp, String hostPath) {294 if (!recordVideoForSession(sessionCapabilities)) {295 return null;296 }297 int videoPort = 9000;298 Map<String, String> envVars = getVideoContainerEnvVars(299 sessionCapabilities,300 browserContainerIp);301 Map<String, String> volumeBinds = Collections.singletonMap(hostPath, "/videos");302 ContainerConfig containerConfig = image(videoImage)303 .env(envVars)304 .bind(volumeBinds)305 .network(networkName);306 if (!runningInDocker) {307 videoPort = PortProber.findFreePort();308 containerConfig = containerConfig.map(Port.tcp(9000), Port.tcp(videoPort));309 }310 Container videoContainer = docker.create(containerConfig);311 videoContainer.start();312 String videoContainerIp = runningInDocker ? videoContainer.inspect().getIp() : "localhost";313 try {314 URL videoContainerUrl = new URL(String.format("http://%s:%s", videoContainerIp, videoPort));315 HttpClient videoClient = clientFactory.createClient(videoContainerUrl);316 LOG.fine(String.format("Waiting for video recording... (id: %s)", videoContainer.getId()));...

Full Screen

Full Screen

Source:DockerSessionFactory.java Github

copy

Full Screen

...22import org.openqa.selenium.SessionNotCreatedException;23import org.openqa.selenium.TimeoutException;24import org.openqa.selenium.WebDriverException;25import org.openqa.selenium.docker.Container;26import org.openqa.selenium.docker.ContainerConfig;27import org.openqa.selenium.docker.ContainerInfo;28import org.openqa.selenium.docker.Docker;29import org.openqa.selenium.docker.Image;30import org.openqa.selenium.docker.Port;31import org.openqa.selenium.grid.data.CreateSessionRequest;32import org.openqa.selenium.grid.node.ActiveSession;33import org.openqa.selenium.grid.node.SessionFactory;34import org.openqa.selenium.internal.Either;35import org.openqa.selenium.internal.Require;36import org.openqa.selenium.json.Json;37import org.openqa.selenium.net.PortProber;38import org.openqa.selenium.remote.Command;39import org.openqa.selenium.remote.Dialect;40import org.openqa.selenium.remote.DriverCommand;41import org.openqa.selenium.remote.ProtocolHandshake;42import org.openqa.selenium.remote.Response;43import org.openqa.selenium.remote.SessionId;44import org.openqa.selenium.remote.http.HttpClient;45import org.openqa.selenium.remote.http.HttpRequest;46import org.openqa.selenium.remote.http.HttpResponse;47import org.openqa.selenium.remote.tracing.AttributeKey;48import org.openqa.selenium.remote.tracing.EventAttribute;49import org.openqa.selenium.remote.tracing.EventAttributeValue;50import org.openqa.selenium.remote.tracing.Span;51import org.openqa.selenium.remote.tracing.Status;52import org.openqa.selenium.remote.tracing.Tracer;53import org.openqa.selenium.support.ui.FluentWait;54import org.openqa.selenium.support.ui.Wait;55import java.io.IOException;56import java.io.UncheckedIOException;57import java.net.MalformedURLException;58import java.net.URI;59import java.net.URL;60import java.nio.charset.Charset;61import java.nio.file.Files;62import java.nio.file.Paths;63import java.time.Duration;64import java.time.Instant;65import java.util.Arrays;66import java.util.Collections;67import java.util.HashMap;68import java.util.Map;69import java.util.Objects;70import java.util.Optional;71import java.util.TimeZone;72import java.util.logging.Level;73import java.util.logging.Logger;74import static java.util.Optional.ofNullable;75import static org.openqa.selenium.docker.ContainerConfig.image;76import static org.openqa.selenium.remote.Dialect.W3C;77import static org.openqa.selenium.remote.http.Contents.string;78import static org.openqa.selenium.remote.http.HttpMethod.GET;79import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;80public class DockerSessionFactory implements SessionFactory {81 private static final Logger LOG = Logger.getLogger(DockerSessionFactory.class.getName());82 private final Tracer tracer;83 private final HttpClient.Factory clientFactory;84 private final Docker docker;85 private final URI dockerUri;86 private final Image browserImage;87 private final Capabilities stereotype;88 private final Image videoImage;89 private final DockerAssetsPath assetsPath;90 private final String networkName;91 private final boolean runningInDocker;92 public DockerSessionFactory(93 Tracer tracer,94 HttpClient.Factory clientFactory,95 Docker docker,96 URI dockerUri,97 Image browserImage,98 Capabilities stereotype,99 Image videoImage,100 DockerAssetsPath assetsPath,101 String networkName,102 boolean runningInDocker) {103 this.tracer = Require.nonNull("Tracer", tracer);104 this.clientFactory = Require.nonNull("HTTP client", clientFactory);105 this.docker = Require.nonNull("Docker command", docker);106 this.dockerUri = Require.nonNull("Docker URI", dockerUri);107 this.browserImage = Require.nonNull("Docker browser image", browserImage);108 this.networkName = Require.nonNull("Docker network name", networkName);109 this.stereotype = ImmutableCapabilities.copyOf(110 Require.nonNull("Stereotype", stereotype));111 this.videoImage = videoImage;112 this.assetsPath = assetsPath;113 this.runningInDocker = runningInDocker;114 }115 @Override116 public boolean test(Capabilities capabilities) {117 return stereotype.getCapabilityNames().stream()118 .map(119 name ->120 Objects.equals(stereotype.getCapability(name), capabilities.getCapability(name)))121 .reduce(Boolean::logicalAnd)122 .orElse(false);123 }124 @Override125 public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sessionRequest) {126 LOG.info("Starting session for " + sessionRequest.getDesiredCapabilities());127 int port = runningInDocker ? 4444 : PortProber.findFreePort();128 try (Span span = tracer.getCurrentContext().createSpan("docker_session_factory.apply")) {129 Map<String, EventAttributeValue> attributeMap = new HashMap<>();130 attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(),131 EventAttribute.setValue(this.getClass().getName()));132 String logMessage = runningInDocker ? "Creating container..." :133 "Creating container, mapping container port 4444 to " + port;134 LOG.info(logMessage);135 Container container = createBrowserContainer(port, sessionRequest.getDesiredCapabilities());136 container.start();137 ContainerInfo containerInfo = container.inspect();138 String containerIp = containerInfo.getIp();139 URL remoteAddress = getUrl(port, containerIp);140 HttpClient client = clientFactory.createClient(remoteAddress);141 attributeMap.put("docker.browser.image", EventAttribute.setValue(browserImage.toString()));142 attributeMap.put("container.port", EventAttribute.setValue(port));143 attributeMap.put("container.id", EventAttribute.setValue(container.getId().toString()));144 attributeMap.put("container.ip", EventAttribute.setValue(containerIp));145 attributeMap.put("docker.server.url", EventAttribute.setValue(remoteAddress.toString()));146 LOG.info(147 String.format("Waiting for server to start (container id: %s, url %s)",148 container.getId(),149 remoteAddress));150 try {151 waitForServerToStart(client, Duration.ofMinutes(1));152 } catch (TimeoutException e) {153 span.setAttribute("error", true);154 span.setStatus(Status.CANCELLED);155 EXCEPTION.accept(attributeMap, e);156 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),157 EventAttribute.setValue(158 "Unable to connect to docker server. Stopping container: " +159 e.getMessage()));160 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);161 container.stop(Duration.ofMinutes(1));162 String message = String.format(163 "Unable to connect to docker server (container id: %s)", container.getId());164 LOG.warning(message);165 return Either.left(new RetrySessionRequestException(message));166 }167 LOG.info(String.format("Server is ready (container id: %s)", container.getId()));168 Command command = new Command(169 null,170 DriverCommand.NEW_SESSION(sessionRequest.getDesiredCapabilities()));171 ProtocolHandshake.Result result;172 Response response;173 try {174 result = new ProtocolHandshake().createSession(client, command);175 response = result.createResponse();176 attributeMap.put(AttributeKey.DRIVER_RESPONSE.getKey(),177 EventAttribute.setValue(response.toString()));178 } catch (IOException | RuntimeException e) {179 span.setAttribute("error", true);180 span.setStatus(Status.CANCELLED);181 EXCEPTION.accept(attributeMap, e);182 attributeMap.put(183 AttributeKey.EXCEPTION_MESSAGE.getKey(),184 EventAttribute185 .setValue("Unable to create session. Stopping and container: " + e.getMessage()));186 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);187 container.stop(Duration.ofMinutes(1));188 String message = "Unable to create session: " + e.getMessage();189 LOG.log(Level.WARNING, message, e);190 return Either.left(new SessionNotCreatedException(message));191 }192 SessionId id = new SessionId(response.getSessionId());193 Capabilities capabilities = new ImmutableCapabilities((Map<?, ?>) response.getValue());194 Capabilities mergedCapabilities = capabilities.merge(sessionRequest.getDesiredCapabilities());195 Container videoContainer = null;196 Optional<DockerAssetsPath> path = ofNullable(this.assetsPath);197 if (path.isPresent()) {198 // Seems we can store session assets199 String containerPath = path.get().getContainerPath(id);200 saveSessionCapabilities(mergedCapabilities, containerPath);201 String hostPath = path.get().getHostPath(id);202 videoContainer = startVideoContainer(mergedCapabilities, containerIp, hostPath);203 }204 Dialect downstream = sessionRequest.getDownstreamDialects().contains(result.getDialect()) ?205 result.getDialect() :206 W3C;207 attributeMap.put(208 AttributeKey.DOWNSTREAM_DIALECT.getKey(),209 EventAttribute.setValue(downstream.toString()));210 attributeMap.put(211 AttributeKey.DRIVER_RESPONSE.getKey(),212 EventAttribute.setValue(response.toString()));213 span.addEvent("Docker driver service created session", attributeMap);214 LOG.fine(String.format(215 "Created session: %s - %s (container id: %s)",216 id,217 capabilities,218 container.getId()));219 return Either.right(new DockerSession(220 container,221 videoContainer,222 tracer,223 client,224 id,225 remoteAddress,226 stereotype,227 mergedCapabilities,228 downstream,229 result.getDialect(),230 Instant.now()));231 }232 }233 private Container createBrowserContainer(int port, Capabilities sessionCapabilities) {234 Map<String, String> browserContainerEnvVars = getBrowserContainerEnvVars(sessionCapabilities);235 Map<String, String> devShmMount = Collections.singletonMap("/dev/shm", "/dev/shm");236 ContainerConfig containerConfig = image(browserImage)237 .env(browserContainerEnvVars)238 .bind(devShmMount)239 .network(networkName);240 if (!runningInDocker) {241 containerConfig = containerConfig.map(Port.tcp(4444), Port.tcp(port));242 }243 return docker.create(containerConfig);244 }245 private Map<String, String> getBrowserContainerEnvVars(Capabilities sessionRequestCapabilities) {246 Optional<Dimension> screenResolution =247 ofNullable(getScreenResolution(sessionRequestCapabilities));248 Map<String, String> envVars = new HashMap<>();249 if (screenResolution.isPresent()) {250 envVars.put("SCREEN_WIDTH", String.valueOf(screenResolution.get().getWidth()));251 envVars.put("SCREEN_HEIGHT", String.valueOf(screenResolution.get().getHeight()));252 }253 Optional<TimeZone> timeZone = ofNullable(getTimeZone(sessionRequestCapabilities));254 timeZone.ifPresent(zone -> envVars.put("TZ", zone.getID()));255 return envVars;256 }257 private Container startVideoContainer(Capabilities sessionCapabilities,258 String browserContainerIp, String hostPath) {259 if (!recordVideoForSession(sessionCapabilities)) {260 return null;261 }262 int videoPort = 9000;263 Map<String, String> envVars = getVideoContainerEnvVars(264 sessionCapabilities,265 browserContainerIp);266 Map<String, String> volumeBinds = Collections.singletonMap(hostPath, "/videos");267 ContainerConfig containerConfig = image(videoImage)268 .env(envVars)269 .bind(volumeBinds)270 .network(networkName);271 if (!runningInDocker) {272 videoPort = PortProber.findFreePort();273 containerConfig = containerConfig.map(Port.tcp(9000), Port.tcp(videoPort));274 }275 Container videoContainer = docker.create(containerConfig);276 videoContainer.start();277 String videoContainerIp = runningInDocker ? videoContainer.inspect().getIp() : "localhost";278 try {279 URL videoContainerUrl = new URL(String.format("http://%s:%s", videoContainerIp, videoPort));280 HttpClient videoClient = clientFactory.createClient(videoContainerUrl);281 LOG.fine(String.format("Waiting for video recording... (id: %s)", videoContainer.getId()));...

Full Screen

Full Screen

Source:V141Docker.java Github

copy

Full Screen

...15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.docker.v1_41;18import org.openqa.selenium.docker.Container;19import org.openqa.selenium.docker.ContainerConfig;20import org.openqa.selenium.docker.ContainerId;21import org.openqa.selenium.docker.ContainerInfo;22import org.openqa.selenium.docker.ContainerLogs;23import org.openqa.selenium.docker.DockerException;24import org.openqa.selenium.docker.DockerProtocol;25import org.openqa.selenium.docker.Image;26import org.openqa.selenium.docker.internal.Reference;27import org.openqa.selenium.internal.Require;28import org.openqa.selenium.remote.http.HttpHandler;29import java.time.Duration;30import java.util.Set;31import java.util.logging.Logger;32public class V141Docker implements DockerProtocol {33 static final String DOCKER_API_VERSION = "1.41";34 private static final Logger LOG = Logger.getLogger(V141Docker.class.getName());35 private final org.openqa.selenium.docker.v1_41.ListImages listImages;36 private final PullImage pullImage;37 private final org.openqa.selenium.docker.v1_41.CreateContainer createContainer;38 private final StartContainer startContainer;39 private final StopContainer stopContainer;40 private final IsContainerPresent isContainerPresent;41 private final org.openqa.selenium.docker.v1_41.InspectContainer inspectContainer;42 private final org.openqa.selenium.docker.v1_41.GetContainerLogs containerLogs;43 public V141Docker(HttpHandler client) {44 Require.nonNull("HTTP client", client);45 listImages = new org.openqa.selenium.docker.v1_41.ListImages(client);46 pullImage = new PullImage(client);47 createContainer = new org.openqa.selenium.docker.v1_41.CreateContainer(this, client);48 startContainer = new StartContainer(client);49 stopContainer = new StopContainer(client);50 isContainerPresent = new IsContainerPresent(client);51 inspectContainer = new org.openqa.selenium.docker.v1_41.InspectContainer(client);52 containerLogs = new org.openqa.selenium.docker.v1_41.GetContainerLogs(client);53 }54 @Override55 public String version() {56 return DOCKER_API_VERSION;57 }58 @Override59 public Image getImage(String imageName) throws DockerException {60 Require.nonNull("Image name", imageName);61 Reference ref = Reference.parse(imageName);62 LOG.info("Listing local images: " + ref);63 Set<Image> allImages = listImages.apply(ref);64 if (!allImages.isEmpty()) {65 return allImages.iterator().next();66 }67 LOG.info("Pulling " + ref);68 pullImage.apply(ref);69 LOG.info("Pull completed. Listing local images again: " + ref);70 allImages = listImages.apply(ref);71 if (!allImages.isEmpty()) {72 return allImages.iterator().next();73 }74 throw new DockerException("Pull appears to have succeeded, but image not present locally: " + imageName);75 }76 @Override77 public Container create(ContainerConfig config) {78 Require.nonNull("Container config", config);79 LOG.fine("Creating container: " + config);80 return createContainer.apply(config);81 }82 @Override83 public boolean isContainerPresent(ContainerId id) throws DockerException {84 Require.nonNull("Container id", id);85 LOG.info("Checking if container is present: " + id);86 return isContainerPresent.apply(id);87 }88 @Override89 public void startContainer(ContainerId id) throws DockerException {90 Require.nonNull("Container id", id);91 LOG.fine("Starting container: " + id);...

Full Screen

Full Screen

Source:ContainerConfig.java Github

copy

Full Screen

...23import java.util.List;24import java.util.Map;25import java.util.stream.Collectors;26@Beta27public class ContainerConfig {28 private static final String DEFAULT_DOCKER_NETWORK = "bridge";29 private final Image image;30 // Port bindings, keyed on the container port, with values being host ports31 private final Multimap<String, Map<String, Object>> portBindings;32 private final Map<String, String> envVars;33 private final Map<String, String> volumeBinds;34 private final String networkName;35 private final boolean autoRemove;36 public ContainerConfig(Image image,37 Multimap<String, Map<String, Object>> portBindings,38 Map<String, String> envVars,39 Map<String, String> volumeBinds, String networkName) {40 this.image = image;41 this.portBindings = portBindings;42 this.envVars = envVars;43 this.volumeBinds = volumeBinds;44 this.networkName = networkName;45 this.autoRemove = true;46 }47 public static ContainerConfig image(Image image) {48 return new ContainerConfig(image, HashMultimap.create(), ImmutableMap.of(), ImmutableMap.of(),49 DEFAULT_DOCKER_NETWORK);50 }51 public ContainerConfig map(Port containerPort, Port hostPort) {52 Require.nonNull("Container port", containerPort);53 Require.nonNull("Host port", hostPort);54 if (!hostPort.getProtocol().equals(containerPort.getProtocol())) {55 throw new DockerException(56 String.format("Port protocols must match: %s -> %s", hostPort, containerPort));57 }58 Multimap<String, Map<String, Object>> updatedBindings = HashMultimap.create(portBindings);59 updatedBindings.put(60 containerPort.getPort() + "/" + containerPort.getProtocol(),61 ImmutableMap.of("HostPort", String.valueOf(hostPort.getPort()), "HostIp", ""));62 return new ContainerConfig(image, updatedBindings, envVars, volumeBinds, networkName);63 }64 public ContainerConfig env(Map<String, String> envVars) {65 Require.nonNull("Container env vars", envVars);66 return new ContainerConfig(image, portBindings, envVars, volumeBinds, networkName);67 }68 public ContainerConfig bind(Map<String, String> volumeBinds) {69 Require.nonNull("Container volume binds", volumeBinds);70 return new ContainerConfig(image, portBindings, envVars, volumeBinds, networkName);71 }72 public ContainerConfig network(String networkName) {73 Require.nonNull("Container network name", networkName);74 return new ContainerConfig(image, portBindings, envVars, volumeBinds, networkName);75 }76 @Override77 public String toString() {78 return "ContainerConfig{" +79 "image=" + image +80 ", portBindings=" + portBindings +81 ", envVars=" + envVars +82 ", volumeBinds=" + volumeBinds +83 ", networkName=" + networkName +84 ", autoRemove=" + autoRemove +85 '}';86 }87 private Map<String, Object> toJson() {88 List<String> envVars = this.envVars.keySet().stream()89 .map(key -> String.format("%s=%s", key, this.envVars.get(key)))90 .collect(Collectors.toList());91 List<String> volumeBinds = this.volumeBinds.keySet().stream()92 .map(key -> String.format("%s:%s", key, this.volumeBinds.get(key)))...

Full Screen

Full Screen

Source:V140Docker.java Github

copy

Full Screen

...15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.docker.v1_40;18import org.openqa.selenium.docker.Container;19import org.openqa.selenium.docker.ContainerConfig;20import org.openqa.selenium.docker.ContainerId;21import org.openqa.selenium.docker.ContainerInfo;22import org.openqa.selenium.docker.ContainerLogs;23import org.openqa.selenium.docker.DockerException;24import org.openqa.selenium.docker.DockerProtocol;25import org.openqa.selenium.docker.Image;26import org.openqa.selenium.docker.internal.Reference;27import org.openqa.selenium.internal.Require;28import org.openqa.selenium.remote.http.HttpHandler;29import java.time.Duration;30import java.util.Set;31import java.util.logging.Logger;32public class V140Docker implements DockerProtocol {33 private static final Logger LOG = Logger.getLogger(V140Docker.class.getName());34 private final ListImages listImages;35 private final PullImage pullImage;36 private final CreateContainer createContainer;37 private final StartContainer startContainer;38 private final StopContainer stopContainer;39 private final IsContainerPresent isContainerPresent;40 private final InspectContainer inspectContainer;41 private final GetContainerLogs containerLogs;42 public V140Docker(HttpHandler client) {43 Require.nonNull("HTTP client", client);44 listImages = new ListImages(client);45 pullImage = new PullImage(client);46 createContainer = new CreateContainer(this, client);47 startContainer = new StartContainer(client);48 stopContainer = new StopContainer(client);49 isContainerPresent = new IsContainerPresent(client);50 inspectContainer = new InspectContainer(client);51 containerLogs = new GetContainerLogs(client);52 }53 @Override54 public String version() {55 return "1.40";56 }57 @Override58 public Image getImage(String imageName) throws DockerException {59 Require.nonNull("Image name", imageName);60 Reference ref = Reference.parse(imageName);61 LOG.info("Listing local images: " + ref);62 Set<Image> allImages = listImages.apply(ref);63 if (!allImages.isEmpty()) {64 return allImages.iterator().next();65 }66 LOG.info("Pulling " + ref);67 pullImage.apply(ref);68 LOG.info("Pull completed. Listing local images again: " + ref);69 allImages = listImages.apply(ref);70 if (!allImages.isEmpty()) {71 return allImages.iterator().next();72 }73 throw new DockerException("Pull appears to have succeeded, but image not present locally: " + imageName);74 }75 @Override76 public Container create(ContainerConfig config) {77 Require.nonNull("Container config", config);78 LOG.fine("Creating container: " + config);79 return createContainer.apply(config);80 }81 @Override82 public boolean isContainerPresent(ContainerId id) throws DockerException {83 Require.nonNull("Container id", id);84 LOG.info("Checking if container is present: " + id);85 return isContainerPresent.apply(id);86 }87 @Override88 public void startContainer(ContainerId id) throws DockerException {89 Require.nonNull("Container id", id);90 LOG.fine("Starting container: " + id);...

Full Screen

Full Screen

Source:CreateContainer.java Github

copy

Full Screen

...15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.docker.v1_41;18import org.openqa.selenium.docker.Container;19import org.openqa.selenium.docker.ContainerConfig;20import org.openqa.selenium.docker.ContainerId;21import org.openqa.selenium.docker.DockerException;22import org.openqa.selenium.docker.DockerProtocol;23import org.openqa.selenium.internal.Require;24import org.openqa.selenium.json.Json;25import org.openqa.selenium.json.JsonException;26import org.openqa.selenium.remote.http.Contents;27import org.openqa.selenium.remote.http.HttpHandler;28import org.openqa.selenium.remote.http.HttpRequest;29import org.openqa.selenium.remote.http.HttpResponse;30import java.util.Collection;31import java.util.Map;32import java.util.logging.Logger;33import java.util.stream.Collectors;34import static org.openqa.selenium.docker.v1_41.V141Docker.DOCKER_API_VERSION;35import static org.openqa.selenium.json.Json.JSON_UTF_8;36import static org.openqa.selenium.json.Json.MAP_TYPE;37import static org.openqa.selenium.remote.http.Contents.asJson;38import static org.openqa.selenium.remote.http.HttpMethod.POST;39class CreateContainer {40 private static final Json JSON = new Json();41 private static final Logger LOG = Logger.getLogger(CreateContainer.class.getName());42 private final DockerProtocol protocol;43 private final HttpHandler client;44 public CreateContainer(DockerProtocol protocol, HttpHandler client) {45 this.protocol = Require.nonNull("Protocol", protocol);46 this.client = Require.nonNull("HTTP client", client);47 }48 public Container apply(ContainerConfig info) {49 HttpResponse res = DockerMessages.throwIfNecessary(50 client.execute(51 new HttpRequest(POST, String.format("/v%s/containers/create", DOCKER_API_VERSION))52 .addHeader("Content-Type", JSON_UTF_8)53 .setContent(asJson(info))),54 "Unable to create container: ",55 info);56 try {57 Map<String, Object> rawContainer = JSON.toType(Contents.string(res), MAP_TYPE);58 if (!(rawContainer.get("Id") instanceof String)) {59 throw new DockerException("Unable to read container id: " + rawContainer);60 }61 ContainerId id = new ContainerId((String) rawContainer.get("Id"));62 if (rawContainer.get("Warnings") instanceof Collection) {...

Full Screen

Full Screen

Source:Docker.java Github

copy

Full Screen

...39 return getDocker()40 .map(protocol -> protocol.getImage(name))41 .orElseThrow(() -> new DockerException("Unable to get image " + name));42 }43 public Container create(ContainerConfig config) {44 Require.nonNull("Container config", config);45 LOG.fine("Creating image from " + config);46 return getDocker()47 .map(protocol -> protocol.create(config))48 .orElseThrow(() -> new DockerException("Unable to create container: " + config));49 }50 public Optional<ContainerInfo> inspect(ContainerId id) {51 Require.nonNull("Container id", id);52 LOG.fine("Inspecting container with id: " + id);53 if (!getDocker().map(protocol -> protocol.isContainerPresent(id)).orElse(false)) {54 return Optional.empty();55 }56 return Optional.of(getDocker()57 .map(protocol -> protocol.inspectContainer(id))...

Full Screen

Full Screen

Source:DockerProtocol.java Github

copy

Full Screen

...18import java.time.Duration;19public interface DockerProtocol {20 String version();21 Image getImage(String imageName) throws DockerException;22 Container create(ContainerConfig info);23 void startContainer(ContainerId id) throws DockerException;24 boolean isContainerPresent(ContainerId id) throws DockerException;25 void stopContainer(ContainerId id, Duration timeout) throws DockerException;26 ContainerInfo inspectContainer(ContainerId id) throws DockerException;27 ContainerLogs getContainerLogs(ContainerId id) throws DockerException;28}...

Full Screen

Full Screen

ContainerConfig

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.docker.ContainerConfig;2import org.openqa.selenium.docker.Docker;3import org.openqa.selenium.docker.DockerContainer;4import org.openqa.selenium.docker.DockerException;5import org.openqa.selenium.docker.DockerImage;6import org.openqa.selenium.docker.ImageName;7import org.openqa.selenium.docker.v1_40.DockerService;8import org.openqa.selenium.remote.http.HttpClient;9import org.openqa.selenium.remote.http.HttpClient.Factory;10import org.openqa.selenium.remote.http.HttpRequest;11import org.openqa.selenium.remote.http.HttpResponse;12import org.openqa.selenium.remote.http.apache.HttpClientFactory;13import java.io.IOException;14import java.net.MalformedURLException;15import java.net.URL;16import java.util.concurrent.TimeUnit;17public class DockerSelenium {18 public static void main(String[] args) throws IOException, InterruptedException, DockerException {19 Factory factory = new HttpClientFactory();20 Docker docker = new DockerService(client);21 ImageName name = new ImageName("selenium/standalone-chrome");22 DockerImage image = docker.getImage(name);23 if (image == null) {24 image = docker.pull(name);25 }26 ContainerConfig config = new ContainerConfig();27 config.withCmd("-port", "4444");28 DockerContainer container = image.create(config);29 container.start();30 container.waitUntilReady(30, TimeUnit.SECONDS);31 HttpRequest request = new HttpRequest(HttpMethod.GET, "/wd/hub/status");32 HttpResponse response = container.makeRequest(request);33 container.stop();34 }35}36import org.openqa.selenium.remote.DesiredCapabilities;37import org.openqa.selenium.remote.RemoteWebDriver;38import java.net.MalformedURLException;39import java.net.URL;40public class SeleniumTest {

Full Screen

Full Screen

ContainerConfig

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.docker.ContainerConfig;2import org.openqa.selenium.docker.DockerContainerConfig;3import org.openqa.selenium.docker.DockerContainerFactory;4import org.openqa.selenium.docker.DockerContainer;5import org.openqa.selenium.docker.DockerService;6import org.openqa.selenium.docker.DockerOptions;7import org.openqa.selenium.docker.DockerDriver;8import org.openqa.selenium.docker.DockerDriverProvider;9import org.openqa.selenium.docker.ContainerConfig;10import org.openqa.selenium.docker.DockerContainerConfig;11import org.openqa.selenium.docker.DockerContainerFactory;12import org.openqa.selenium.docker.DockerContainer;13import org.openqa.selenium.docker.DockerService;14import org.openqa.selenium.docker.DockerOptions;15import org.openqa.selenium.docker.DockerDriver;16import org.openqa.selenium.docker.DockerDriverProvider;17import org.openqa.selenium.docker.ContainerConfig;18import org.openqa.selenium.docker.DockerContainerConfig;19import org.openqa.selenium.docker.DockerContainerFactory;20import org.openqa.selenium.docker.DockerContainer;21import org.openqa.selenium.docker.DockerService;22import org.openqa.selenium.docker.DockerOptions;23import org.openqa.selenium.docker.DockerDriver;24import org.openqa.selenium.docker.DockerDriverProvider;25import org.openqa.selenium.docker.ContainerConfig;26import org.openqa.selenium.docker.DockerContainerConfig;27import org.openqa.selenium.docker.DockerContainerFactory;28import org.openqa.selenium.docker.DockerContainer;29import org.openqa.selenium.docker.DockerService;30import org.openqa.selenium.docker.DockerOptions;31import org.openqa.selenium.docker.DockerDriver;32import org.openqa.selenium.docker.DockerDriverProvider;33import org.openqa.selenium.docker.ContainerConfig;34import org.openqa.selenium.docker.DockerContainerConfig;35import org.openqa.selenium.docker.DockerContainerFactory;36import org.openqa.selenium.docker.DockerContainer;37import org.openqa.selenium.docker.DockerService;38import org.openqa.selenium.docker.DockerOptions;39import org.openqa.selenium.docker.DockerDriver;40import org.openqa.selenium.docker.DockerDriverProvider;41import org.openqa.selenium.docker.ContainerConfig;42import org.openqa.selenium.docker.DockerContainerConfig;43import org.openqa.selenium.docker.DockerContainerFactory

Full Screen

Full Screen

ContainerConfig

Using AI Code Generation

copy

Full Screen

1Docker docker = new Docker();2DockerOptions dockerOptions = new DockerOptions();3dockerOptions.setHost("localhost");4dockerOptions.setPort(2375);5dockerOptions.setTlsVerify(false);6dockerOptions.setCertPath("/home/user/.docker");7dockerOptions.setApiVersion("1.35");8docker.setOptions(dockerOptions);9ContainerConfig containerConfig = new ContainerConfig();10containerConfig.setImage("selenium/standalone-chrome:3.141.59-20200129");11Port port = new Port();12port.setNumber(4444);13PortBinding portBinding = new PortBinding();14portBinding.setHostIp("

Full Screen

Full Screen

ContainerConfig

Using AI Code Generation

copy

Full Screen

1DockerServiceBuilder dockerServiceBuilder = new DockerServiceBuilder();2DockerService dockerService = dockerServiceBuilder.build();3DockerImageBuilder dockerImageBuilder = new DockerImageBuilder();4DockerImage dockerImage = dockerImageBuilder.build();5ContainerConfigBuilder containerConfigBuilder = new ContainerConfigBuilder();6ContainerConfig containerConfig = containerConfigBuilder.build();7DockerSessionOptionsBuilder dockerSessionOptionsBuilder = new DockerSessionOptionsBuilder();8DockerSessionOptions dockerSessionOptions = dockerSessionOptionsBuilder.build();9DockerSessionFactoryBuilder dockerSessionFactoryBuilder = new DockerSessionFactoryBuilder();10DockerSessionFactory dockerSessionFactory = dockerSessionFactoryBuilder.build();11DockerSession dockerSession = dockerSessionFactory.createSession(dockerSessionOptions);12dockerSession.getContainerId();13dockerSession.getContainerIpAddress();14dockerSession.getContainerPort(8080);15dockerSession.getContainerStatus();

Full Screen

Full Screen

ContainerConfig

Using AI Code Generation

copy

Full Screen

1ContainerConfig config = ContainerConfig.builder()2 .withImage("selenium/standalone-chrome")3 .withPortBindings(4444)4 .withEnv("SCREEN_WIDTH", "1920")5 .withEnv("SCREEN_HEIGHT", "1080")6 .withEnv("TZ", "Europe/London")7 .build();8DockerContainer container = new DockerContainer(config);9container.start();10String ip = container.getIpAddress();11int port = container.getPort();12container.stop();13container.remove();14ContainerConfig config = ContainerConfig.builder()15 .withImage("selenium/standalone-chrome")16 .withPortBindings(4444)17 .withEnv("SCREEN_WIDTH", "1920")18 .withEnv("SCREEN_HEIGHT", "1080")19 .withEnv("TZ", "Europe/London")20 .build();21DockerContainer container = new DockerContainer(config);22container.start();23String ip = container.getIpAddress();24int port = container.getPort();25container.stop();26container.remove();27ContainerConfig config = ContainerConfig.builder()28 .withImage("selenium/standalone-chrome")29 .withPortBindings(4444)30 .withEnv("SCREEN_WIDTH", "1920")31 .withEnv("SCREEN_HEIGHT", "1080")32 .withEnv("TZ", "Europe/London")33 .build();34DockerContainer container = new DockerContainer(config);

Full Screen

Full Screen
copy
1public <T> T getValue(String component, String key, T defaultValue, Function<String, T> parser) throws ConfigException {2 try {3 String value = this.getString( component, key, String.valueOf(defaultValue) );4 return parser.apply(value);5 } catch (Exception e) {6 logger.log(Level.SEVERE, e.getMessage(), e);7 throw new ConfigException( e.getMessage(), e.getCause() );8 }9}1011public Integer getInteger(String component, String key, int defaultValue) throws ConfigException {12 return getValue(component, key, defaultValue, Integer::parseInt );13}1415public Double getDouble(String component, String key, double defaultValue) throws ConfigException {16 return getValue(component, key, defaultValue, Double::parseDouble );17}1819public Boolean getBoolean (String component, String key, boolean defaultValue) throws ConfigException {20 return getValue(component, key, defaultValue, Boolean::parseBoolean);21}22
Full Screen
copy
1private <T> T getT(String component, String key, T defaultValue, Function<String, T> parser) {2 try {3 return parser.apply(this.getString(component, key, String.valueOf(defaultValue)));4 } catch (Exception e) {5 logger.log(Level.SEVERE, e.getMessage(), e);6 throw new ConfigException(e.getMessage(), e.getCause());7 }8}9
Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in ContainerConfig

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful