How to use setValue method of org.openqa.selenium.remote.tracing.EventAttribute class

Best Selenium code snippet using org.openqa.selenium.remote.tracing.EventAttribute.setValue

Source:RedisBackedSessionMap.java Github

copy

Full Screen

...101 span.setAttribute(REDIS_URI_VALUE, uriValue);102 span.setAttribute(REDIS_CAPABILITIES_KEY, capabilitiesKey);103 span.setAttribute(REDIS_CAPABILITIES_VALUE, capabilitiesJson);104 span.setAttribute(DATABASE_OPERATION, "MSET");105 attributeMap.put(REDIS_URI_KEY, EventAttribute.setValue(uriKey));106 attributeMap.put(REDIS_URI_VALUE, EventAttribute.setValue(uriValue));107 attributeMap.put(REDIS_CAPABILITIES_KEY, EventAttribute.setValue(capabilitiesKey));108 attributeMap.put(REDIS_CAPABILITIES_VALUE, EventAttribute.setValue(capabilitiesJson));109 attributeMap.put(REDIS_START_KEY, EventAttribute.setValue(startKey));110 attributeMap.put(REDIS_START_VALUE, EventAttribute.setValue(startValue));111 attributeMap.put(DATABASE_OPERATION, EventAttribute.setValue("MSET"));112 span.addEvent("Inserted into the database", attributeMap);113 connection.mset(114 ImmutableMap.of(115 uriKey, uriValue,116 stereotypeKey, stereotypeJson,117 capabilitiesKey, capabilitiesJson,118 startKey, startValue));119 return true;120 }121 }122 @Override123 public Session get(SessionId id) throws NoSuchSessionException {124 Require.nonNull("Session ID", id);125 try (Span span = tracer.getCurrentContext().createSpan("GET capabilitiesKey")) {126 Map<String, EventAttributeValue> attributeMap = new HashMap<>();127 SESSION_ID.accept(span, id);128 SESSION_ID_EVENT.accept(attributeMap, id);129 setCommonSpanAttributes(span);130 setCommonEventAttributes(attributeMap);131 span.setAttribute(DATABASE_OPERATION, "GET");132 attributeMap.put(DATABASE_OPERATION, EventAttribute.setValue("GET"));133 URI uri = getUri(id);134 attributeMap.put(REDIS_URI_KEY, EventAttribute.setValue(uriKey(id)));135 attributeMap.put(AttributeKey.SESSION_URI.getKey(), EventAttribute.setValue(uri.toString()));136 String capabilitiesKey = capabilitiesKey(id);137 String rawCapabilities = connection.get(capabilitiesKey);138 String sterotypeKey = stereotypeKey(id);139 String rawStereotype = connection.get(sterotypeKey);140 span.setAttribute(REDIS_CAPABILITIES_KEY, capabilitiesKey);141 attributeMap.put(REDIS_CAPABILITIES_KEY, EventAttribute.setValue(capabilitiesKey));142 if (rawCapabilities != null) {143 span.setAttribute(REDIS_CAPABILITIES_VALUE, rawCapabilities);144 }145 Capabilities caps = rawCapabilities == null ?146 new ImmutableCapabilities() :147 JSON.toType(rawCapabilities, Capabilities.class);148 Capabilities sterotype = rawStereotype == null ?149 new ImmutableCapabilities() :150 JSON.toType(rawStereotype, Capabilities.class);151 String rawStart = connection.get(startKey(id));152 Instant start = JSON.toType(rawStart, Instant.class);153 CAPABILITIES.accept(span, caps);154 CAPABILITIES_EVENT.accept(attributeMap, caps);155 span.addEvent("Retrieved session from the database", attributeMap);156 return new Session(id, uri, sterotype, caps, start);157 }158 }159 @Override160 public URI getUri(SessionId id) throws NoSuchSessionException {161 Require.nonNull("Session ID", id);162 try (Span span = tracer.getCurrentContext().createSpan("GET sessionURI")) {163 Map<String, EventAttributeValue> attributeMap = new HashMap<>();164 SESSION_ID.accept(span, id);165 SESSION_ID_EVENT.accept(attributeMap, id);166 setCommonSpanAttributes(span);167 setCommonEventAttributes(attributeMap);168 span.setAttribute(DATABASE_OPERATION, "GET");169 attributeMap.put(DATABASE_OPERATION, EventAttribute.setValue("GET"));170 String uriKey = uriKey(id);171 List<KeyValue<String, String>> rawValues = connection.mget(uriKey);172 String rawUri = rawValues.get(0).getValueOrElse(null);173 span.setAttribute(REDIS_URI_KEY, uriKey);174 attributeMap.put(REDIS_URI_KEY, EventAttribute.setValue(uriKey));175 if (rawUri == null) {176 NoSuchSessionException exception = new NoSuchSessionException("Unable to find session.");177 span.setAttribute("error", true);178 span.setStatus(Status.NOT_FOUND);179 EXCEPTION.accept(attributeMap, exception);180 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),181 EventAttribute.setValue("Session URI does not exist in the database :" + exception.getMessage()));182 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);183 throw exception;184 }185 span.setAttribute(REDIS_URI_VALUE, rawUri);186 attributeMap.put(REDIS_URI_KEY, EventAttribute.setValue(uriKey));187 attributeMap.put(REDIS_URI_VALUE, EventAttribute.setValue(rawUri));188 try {189 return new URI(rawUri);190 } catch (URISyntaxException e) {191 span.setAttribute("error", true);192 span.setStatus(Status.INTERNAL);193 EXCEPTION.accept(attributeMap, e);194 attributeMap.put(AttributeKey.SESSION_URI.getKey(), EventAttribute.setValue(rawUri));195 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),196 EventAttribute.setValue("Unable to convert session id to uri: " + e.getMessage()));197 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);198 throw new NoSuchSessionException(String.format("Unable to convert session id (%s) to uri: %s", id, rawUri), e);199 }200 }201 }202 @Override203 public void remove(SessionId id) {204 Require.nonNull("Session ID", id);205 try (Span span = tracer.getCurrentContext().createSpan("DEL sessionUriKey capabilitiesKey")) {206 Map<String, EventAttributeValue> attributeMap = new HashMap<>();207 SESSION_ID.accept(span, id);208 SESSION_ID_EVENT.accept(attributeMap, id);209 setCommonSpanAttributes(span);210 setCommonEventAttributes(attributeMap);211 span.setAttribute(DATABASE_OPERATION, "DEL");212 attributeMap.put(DATABASE_OPERATION, EventAttribute.setValue("DEL"));213 String uriKey = uriKey(id);214 String capabilitiesKey = capabilitiesKey(id);215 span.setAttribute(REDIS_URI_KEY, uriKey);216 span.setAttribute(REDIS_CAPABILITIES_KEY, capabilitiesKey);217 attributeMap.put(REDIS_URI_KEY, EventAttribute.setValue(uriKey));218 attributeMap.put(REDIS_CAPABILITIES_KEY, EventAttribute.setValue(capabilitiesKey));219 span.addEvent("Deleted session from the database", attributeMap);220 connection.del(uriKey, capabilitiesKey);221 }222 }223 @Override224 public boolean isReady() {225 return connection.isOpen();226 }227 private String uriKey(SessionId id) {228 Require.nonNull("Session ID", id);229 return "session:" + id.toString() + ":uri";230 }231 private String capabilitiesKey(SessionId id) {232 Require.nonNull("Session ID", id);233 return "session:" + id.toString() + ":capabilities";234 }235 private String startKey(SessionId id) {236 Require.nonNull("Session ID", id);237 return "session:" + id.toString() + ":start";238 }239 private String stereotypeKey(SessionId id) {240 Require.nonNull("Session ID", id);241 return "session:" + id.toString() + ":stereotype";242 }243 private void setCommonSpanAttributes(Span span) {244 span.setAttribute("span.kind", Span.Kind.CLIENT.toString());245 span.setAttribute(DATABASE_SYSTEM, "redis");246 }247 private void setCommonEventAttributes(Map<String, EventAttributeValue> map) {248 map.put(DATABASE_SYSTEM, EventAttribute.setValue("redis"));249 if (serverUri != null) {250 map.put(AttributeKey.DATABASE_CONNECTION_STRING.getKey(),251 EventAttribute.setValue(serverUri.toString()));252 }253 }254}...

Full Screen

Full Screen

Source:GridStatusHandler.java Github

copy

Full Screen

...84 long start = System.currentTimeMillis();85 try (Span span = newSpanAsChildOf(tracer, req, "router.status")) {86 Map<String, EventAttributeValue> attributeMap = new HashMap<>();87 attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(),88 EventAttribute.setValue(getClass().getName()));89 DistributorStatus status;90 try {91 status = EXECUTOR_SERVICE.submit(span.wrap(distributor::getStatus)).get(2, SECONDS);92 } catch (ExecutionException | TimeoutException e) {93 span.setAttribute("error", true);94 span.setStatus(Status.CANCELLED);95 EXCEPTION.accept(attributeMap, e);96 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),97 EventAttribute.setValue("Unable to get distributor status due to execution error or timeout: " + e.getMessage()));98 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);99 return new HttpResponse().setContent(asJson(100 ImmutableMap.of("value", ImmutableMap.of(101 "ready", false,102 "message", "Unable to read distributor status."))));103 } catch (InterruptedException e) {104 span.setAttribute("error", true);105 span.setStatus(Status.ABORTED);106 EXCEPTION.accept(attributeMap, e);107 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),108 EventAttribute.setValue("Interruption while getting distributor status: " + e.getMessage()));109 Thread.currentThread().interrupt();110 return new HttpResponse().setContent(asJson(111 ImmutableMap.of("value", ImmutableMap.of(112 "ready", false,113 "message", "Reading distributor status was interrupted."))));114 }115 boolean ready = status.hasCapacity();116 long remaining = System.currentTimeMillis() + 2000 - start;117 List<Future<Map<String, Object>>> nodeResults = status.getNodes().stream()118 .map(node -> {119 ImmutableMap<String, Object> defaultResponse = ImmutableMap.of(120 "id", node.getId(),121 "uri", node.getUri(),122 "maxSessions", node.getMaxSessionCount(),123 "slots", node.getSlots(),124 "warning", "Unable to read data from node.");125 CompletableFuture<Map<String, Object>> toReturn = new CompletableFuture<>();126 Future<?> future = EXECUTOR_SERVICE.submit(127 () -> {128 try {129 HttpClient client = clientFactory.createClient(node.getUri().toURL());130 HttpRequest nodeStatusReq = new HttpRequest(GET, "/se/grid/node/status");131 HttpTracing.inject(tracer, span, nodeStatusReq);132 HttpResponse res = client.execute(nodeStatusReq);133 toReturn.complete(res.getStatus() == 200134 ? json.toType(string(res), MAP_TYPE)135 : defaultResponse);136 } catch (IOException e) {137 toReturn.complete(defaultResponse);138 }139 });140 SCHEDULED_SERVICE.schedule(141 () -> {142 if (!toReturn.isDone()) {143 toReturn.complete(defaultResponse);144 future.cancel(true);145 }146 },147 remaining,148 MILLISECONDS);149 return toReturn;150 })151 .collect(toList());152 ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();153 value.put("ready", ready);154 value.put("message", ready ? "Selenium Grid ready." : "Selenium Grid not ready.");155 value.put("nodes", nodeResults.stream()156 .map(summary -> {157 try {158 return summary.get();159 } catch (ExecutionException e) {160 span.setAttribute("error", true);161 span.setStatus(Status.NOT_FOUND);162 EXCEPTION.accept(attributeMap, e);163 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),164 EventAttribute.setValue("Unable to get Node information: " + e.getMessage()));165 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);166 throw wrap(e);167 } catch (InterruptedException e) {168 span.setAttribute("error", true);169 span.setStatus(Status.NOT_FOUND);170 EXCEPTION.accept(attributeMap, e);171 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),172 EventAttribute.setValue("Unable to get Node information: " + e.getMessage()));173 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);174 Thread.currentThread().interrupt();175 throw wrap(e);176 }177 })178 .collect(toList()));179 HttpResponse res = new HttpResponse().setContent(asJson(ImmutableMap.of("value", value.build())));180 HTTP_RESPONSE.accept(span, res);181 HTTP_RESPONSE_EVENT.accept(attributeMap, res);182 attributeMap.put("grid.status", EventAttribute.setValue(ready));183 span.setStatus(Status.OK);184 span.addEvent("Computed grid status", attributeMap);185 return res;186 }187 }188 private RuntimeException wrap(Exception e) {189 if (e instanceof InterruptedException) {190 Thread.currentThread().interrupt();191 return new RuntimeException(e);192 }193 Throwable cause = e.getCause();194 if (cause == null) {195 return e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);196 }...

Full Screen

Full Screen

Source:ProtocolConverter.java Github

copy

Full Screen

...104 public HttpResponse execute(HttpRequest req) throws UncheckedIOException {105 try (Span span = newSpanAsChildOf(tracer, req, "protocol_converter")) {106 Map<String, EventAttributeValue> attributeMap = new HashMap<>();107 attributeMap.put(AttributeKey.HTTP_HANDLER_CLASS.getKey(),108 EventAttribute.setValue(getClass().getName()));109 Command command = downstream.decode(req);110 KIND.accept(span, Span.Kind.SERVER);111 HTTP_REQUEST.accept(span, req);112 HTTP_REQUEST_EVENT.accept(attributeMap, req);113 SessionId sessionId = command.getSessionId();114 SESSION_ID.accept(span, sessionId);115 SESSION_ID_EVENT.accept(attributeMap, sessionId);116 String commandName = command.getName();117 span.setAttribute("command.name", commandName);118 attributeMap.put("command.name", EventAttribute.setValue(commandName));119 attributeMap.put("downstream.command.parameters", EventAttribute.setValue(command.getParameters().toString()));120 // Massage the webelements121 @SuppressWarnings("unchecked")122 Map<String, ?> parameters = (Map<String, ?>) converter.apply(command.getParameters());123 command = new Command(124 command.getSessionId(),125 command.getName(),126 parameters);127 attributeMap.put("upstream.command.parameters", EventAttribute.setValue(command.getParameters().toString()));128 HttpRequest request = upstream.encode(command);129 HttpTracing.inject(tracer, span, request);130 HttpResponse res = makeRequest(request);131 if(!res.isSuccessful()) {132 span.setAttribute("error", true);133 span.setStatus(Status.UNKNOWN);134 }135 HTTP_RESPONSE.accept(span, res);136 HTTP_RESPONSE_EVENT.accept(attributeMap, res);137 HttpResponse toReturn;138 if (DriverCommand.NEW_SESSION.equals(command.getName()) && res.getStatus() == HTTP_OK) {139 toReturn = newSessionConverter.apply(res);140 } else {141 Response decoded = upstreamResponse.decode(res);...

Full Screen

Full Screen

Source:DockerSessionFactory.java Github

copy

Full Screen

...97 HttpClient client = clientFactory.createClient(remoteAddress);98 try (Span span = tracer.getCurrentContext().createSpan("docker_session_factory.apply")) {99 Map<String, EventAttributeValue> attributeMap = new HashMap<>();100 attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(),101 EventAttribute.setValue(this.getClass().getName()));102 LOG.info("Creating container, mapping container port 4444 to " + port);103 Container container = docker.create(image(image).map(Port.tcp(4444), Port.tcp(port)));104 container.start();105 attributeMap.put("docker.image", EventAttribute.setValue(image.toString()));106 attributeMap.put("container.port", EventAttribute.setValue(port));107 attributeMap.put("container.id", EventAttribute.setValue(container.getId().toString()));108 attributeMap.put("docker.server.url", EventAttribute.setValue(remoteAddress.toString()));109 LOG.info(String.format("Waiting for server to start (container id: %s)", container.getId()));110 try {111 waitForServerToStart(client, Duration.ofMinutes(1));112 span.addEvent("Container started. Docker server ready.", attributeMap);113 } catch (TimeoutException e) {114 span.setAttribute("error", true);115 span.setStatus(Status.CANCELLED);116 EXCEPTION.accept(attributeMap, e);117 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),118 EventAttribute.setValue("Unable to connect to docker server. Stopping container: " + e.getMessage()));119 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);120 container.stop(Duration.ofMinutes(1));121 container.delete();122 LOG.warning(String.format(123 "Unable to connect to docker server (container id: %s)", container.getId()));124 return Optional.empty();125 }126 LOG.info(String.format("Server is ready (container id: %s)", container.getId()));127 Command command = new Command(128 null,129 DriverCommand.NEW_SESSION(sessionRequest.getCapabilities()));130 ProtocolHandshake.Result result;131 Response response;132 try {133 result = new ProtocolHandshake().createSession(client, command);134 response = result.createResponse();135 attributeMap.put(AttributeKey.DRIVER_RESPONSE.getKey(), EventAttribute.setValue(response.toString()));136 } catch (IOException | RuntimeException e) {137 span.setAttribute("error", true);138 span.setStatus(Status.CANCELLED);139 EXCEPTION.accept(attributeMap, e);140 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),141 EventAttribute.setValue("Unable to create session. Stopping and container: " + e.getMessage()));142 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);143 container.stop(Duration.ofMinutes(1));144 container.delete();145 LOG.log(Level.WARNING, "Unable to create session: " + e.getMessage(), e);146 return Optional.empty();147 }148 SessionId id = new SessionId(response.getSessionId());149 Capabilities capabilities = new ImmutableCapabilities((Map<?, ?>) response.getValue());150 Dialect downstream = sessionRequest.getDownstreamDialects().contains(result.getDialect()) ?151 result.getDialect() :152 W3C;153 attributeMap.put(AttributeKey.DOWNSTREAM_DIALECT.getKey(), EventAttribute.setValue(downstream.toString()));154 attributeMap.put(AttributeKey.DRIVER_RESPONSE.getKey(), EventAttribute.setValue(response.toString()));155 span.addEvent("Docker driver service created session", attributeMap);156 LOG.info(String.format(157 "Created session: %s - %s (container id: %s)",158 id,159 capabilities,160 container.getId()));161 return Optional.of(new DockerSession(162 container,163 tracer,164 client,165 id,166 remoteAddress,167 stereotype,168 capabilities,...

Full Screen

Full Screen

Source:DriverServiceSessionFactory.java Github

copy

Full Screen

...84 Map<String, EventAttributeValue> attributeMap = new HashMap<>();85 Capabilities capabilities = sessionRequest.getCapabilities();86 CAPABILITIES.accept(span, capabilities);87 CAPABILITIES_EVENT.accept(attributeMap, capabilities);88 attributeMap.put(AttributeKey.LOGGER_CLASS.getKey(), EventAttribute.setValue(this.getClass().getName()));89 DriverService service = builder.build();90 try {91 service.start();92 URL serviceURL = service.getUrl();93 attributeMap.put(AttributeKey.DRIVER_URL.getKey(), EventAttribute.setValue(serviceURL.toString()));94 HttpClient client = clientFactory.createClient(serviceURL);95 Command command = new Command(96 null,97 DriverCommand.NEW_SESSION(sessionRequest.getCapabilities()));98 ProtocolHandshake.Result result = new ProtocolHandshake().createSession(client, command);99 Set<Dialect> downstreamDialects = sessionRequest.getDownstreamDialects();100 Dialect upstream = result.getDialect();101 Dialect downstream = downstreamDialects.contains(result.getDialect()) ?102 result.getDialect() :103 downstreamDialects.iterator().next();104 Response response = result.createResponse();105 attributeMap.put(AttributeKey.UPSTREAM_DIALECT.getKey(), EventAttribute.setValue(upstream.toString()));106 attributeMap.put(AttributeKey.DOWNSTREAM_DIALECT.getKey(), EventAttribute.setValue(downstream.toString()));107 attributeMap.put(AttributeKey.DRIVER_RESPONSE.getKey(), EventAttribute.setValue(response.toString()));108 // TODO: This is a nasty hack. Try and make it elegant.109 Capabilities caps = new ImmutableCapabilities((Map<?, ?>) response.getValue());110 Optional<URI> reportedUri = ChromiumDevToolsLocator.getReportedUri("goog:chromeOptions", caps);111 if (reportedUri.isPresent()) {112 caps = addCdpCapability(caps, reportedUri.get());113 } else {114 reportedUri = ChromiumDevToolsLocator.getReportedUri("ms:edgeOptions", caps);115 if (reportedUri.isPresent()) {116 caps = addCdpCapability(caps, reportedUri.get());117 }118 }119 span.addEvent("Driver service created session", attributeMap);120 return Optional.of(121 new ProtocolConvertingSession(122 tracer,123 client,124 new SessionId(response.getSessionId()),125 service.getUrl(),126 downstream,127 upstream,128 stereotype,129 caps,130 Instant.now()) {131 @Override132 public void stop() {133 service.stop();134 }135 });136 } catch (Exception e) {137 span.setAttribute("error", true);138 span.setStatus(Status.CANCELLED);139 EXCEPTION.accept(attributeMap, e);140 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),141 EventAttribute.setValue("Error while creating session with the driver service. Stopping driver service: " + e.getMessage()));142 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);143 service.stop();144 return Optional.empty();145 }146 } catch (Exception e) {147 return Optional.empty();148 }149 }150 private Capabilities addCdpCapability(Capabilities caps, URI uri) {151 Object raw = caps.getCapability("se:options");152 if (!(raw instanceof Map)) {153 return new PersistentCapabilities(caps).setCapability("se:options", ImmutableMap.of("cdp", uri));154 }155 //noinspection unchecked...

Full Screen

Full Screen

Source:HandleSession.java Github

copy

Full Screen

...68 public HttpResponse execute(HttpRequest req) {69 try (Span span = HttpTracing.newSpanAsChildOf(tracer, req, "router.handle_session")) {70 Map<String, EventAttributeValue> attributeMap = new HashMap<>();71 attributeMap.put(AttributeKey.HTTP_HANDLER_CLASS.getKey(),72 EventAttribute.setValue(getClass().getName()));73 HTTP_REQUEST.accept(span, req);74 HTTP_REQUEST_EVENT.accept(attributeMap, req);75 SessionId id = getSessionId(req.getUri()).map(SessionId::new)76 .orElseThrow(() -> {77 NoSuchSessionException exception = new NoSuchSessionException("Cannot find session: " + req);78 EXCEPTION.accept(attributeMap, exception);79 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),80 EventAttribute.setValue(81 "Unable to execute request for an existing session: " + exception.getMessage()));82 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);83 return exception;84 });85 SESSION_ID.accept(span, id);86 SESSION_ID_EVENT.accept(attributeMap, id);87 try {88 HttpTracing.inject(tracer, span, req);89 HttpResponse res = knownSessions.get(id, loadSessionId(tracer, span, id)).execute(req);90 HTTP_RESPONSE.accept(span, res);91 HTTP_RESPONSE_EVENT.accept(attributeMap, res);92 span.addEvent("Session request execution complete", attributeMap);93 return res;94 } catch (ExecutionException e) {95 span.setAttribute("error", true);96 span.setStatus(Status.CANCELLED);97 EXCEPTION.accept(attributeMap, e);98 attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(),99 EventAttribute.setValue("Unable to execute request for an existing session: " + e.getMessage()));100 span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap);101 Throwable cause = e.getCause();102 if (cause instanceof RuntimeException) {103 throw (RuntimeException) cause;104 }105 throw new RuntimeException(cause);106 }107 }108 }109 private Callable<HttpHandler> loadSessionId(Tracer tracer, Span span, SessionId id) {110 return span.wrap(111 () -> {112 Session session = sessions.get(id);113 if (session instanceof HttpHandler) {...

Full Screen

Full Screen

Source:RemoteTags.java Github

copy

Full Screen

...35 public static final BiConsumer<Map<String, EventAttributeValue>, Capabilities>36 CAPABILITIES_EVENT =37 (map, caps) ->38 map.put(AttributeKey.SESSION_CAPABILITIES.getKey(),39 EventAttribute.setValue(String.valueOf(caps)));40 public static final BiConsumer<Map<String, EventAttributeValue>, SessionId>41 SESSION_ID_EVENT =42 (map, id) ->43 map.put(AttributeKey.SESSION_ID.getKey(), EventAttribute.setValue(String.valueOf(id)));44}...

Full Screen

Full Screen

setValue

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.tracing.EventAttribute;2import org.openqa.selenium.remote.tracing.EventAttributeValue;3public class EventAttributeExample {4 public static void main(String[] args) {5 EventAttribute eventAttribute = new EventAttribute("key");6 eventAttribute.setValue(EventAttributeValue.stringAttributeValue("value"));7 System.out.println(eventAttribute.getKey());8 System.out.println(eventAttribute.getValue().getStringValue());9 }10}

Full Screen

Full Screen

setValue

Using AI Code Generation

copy

Full Screen

1package org.openqa.selenium.remote.tracing;2import java.util.Objects;3public final class EventAttribute {4 private final String name;5 private final EventType type;6 private final Object value;7 public EventAttribute(String name, EventType type, Object value) {8 Objects.requireNonNull(name, "Name must be set");9 Objects.requireNonNull(type, "Type must be set");10 Objects.requireNonNull(value, "Value must be set");11 this.name = name;12 this.type = type;13 this.value = value;14 }15 public String getName() {16 return name;17 }18 public EventType getType() {19 return type;20 }21 public Object getValue() {22 return value;23 }24 public EventAttribute setValue(Object value) {25 return new EventAttribute(name, type, value);26 }27 public EventAttribute getScope() {28 return new EventAttribute(name, type, value);29 }30 public String getKey() {31 return name;32 }33 public boolean equals(Object o) {34 if (this == o) {35 return true;36 }37 if (o == null || getClass() != o.getClass()) {38 return false;39 }40 EventAttribute that = (EventAttribute) o;41 return Objects.equals(name, that.name) &&

Full Screen

Full Screen

setValue

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.tracing.EventAttribute;2import org.openqa.selenium.remote.tracing.EventAttributeValue;3EventAttributeValue<String> value = EventAttribute.setValue("value");4System.out.println(value.getValue());5import org.openqa.selenium.remote.tracing.EventAttribute;6import org.openqa.selenium.remote.tracing.EventAttributeValue;7EventAttributeValue<Integer> value = EventAttribute.setValue(1);8System.out.println(value.getValue());9import org.openqa.selenium.remote.tracing.EventAttribute;10import org.openqa.selenium.remote.tracing.EventAttributeValue;11EventAttributeValue<Long> value = EventAttribute.setValue(1L);12System.out.println(value.getValue());13import org.openqa.selenium.remote.tracing.EventAttribute;14import org.openqa.selenium.remote.tracing.EventAttributeValue;15EventAttributeValue<Double> value = EventAttribute.setValue(1.0);16System.out.println(value.getValue());17import org.openqa.selenium.remote.tracing.EventAttribute;18import org.openqa.selenium.remote.tracing.EventAttributeValue;19EventAttributeValue<Boolean> value = EventAttribute.setValue(true);20System.out.println(value.getValue());21import org.openqa.selenium.remote.tracing.EventAttribute;22import org.openqa.selenium.remote.tracing.EventAttributeValue;23String[] values = {"value1", "value2"};24EventAttributeValue<String[]> value = EventAttribute.setValue(values);25System.out.println(Arrays.toString(value.getValue()));26import org.openqa.selenium.remote.tracing.EventAttribute;27import org.openqa.selenium.remote.tracing.EventAttributeValue;28Integer[] values = {1, 2};29EventAttributeValue<Integer[]> value = EventAttribute.setValue(values);30System.out.println(Arrays.toString(value.getValue()));

Full Screen

Full Screen

setValue

Using AI Code Generation

copy

Full Screen

1EventAttribute attribute = new EventAttribute("value", "String", "hello world");2String value = attribute.getValue();3String name = attribute.getName();4String type = attribute.getType();5String str = attribute.toString();6boolean isEqual = attribute.equals(attribute);7EventAttribute(String name, String type, String value) Constructor of EventAttribute class. Parameters: name - name of attribute type - type of attribute value - value of attribute8getValue() Returns value of attribute. Returns: value of attribute9getName() Returns name of attribute. Returns: name of attribute10getType() Returns type of attribute. Returns: type of attribute11toString() Returns string representation of attribute. Returns: string representation of attribute12equals(Object obj) Checks if attribute is equal to another attribute. Parameters: obj - another attribute Returns: true if attribute is equal to another attribute, false otherwise13public EventAttribute(14public String getValue()15public String getName()16public String getType()17public String toString()18public boolean equals(

Full Screen

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 method in EventAttribute

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful