How to use SessionId class of org.openqa.selenium.remote package

Best Selenium code snippet using org.openqa.selenium.remote.SessionId

Source:W3CHttpCommandCodec.java Github

copy

Full Screen

1// Licensed to the Software Freedom Conservancy (SFC) under one2// or more contributor license agreements. See the NOTICE file3// distributed with this work for additional information4// regarding copyright ownership. The SFC licenses this file5// to you under the Apache License, Version 2.0 (the6// "License"); you may not use this file except in compliance7// with the License. You may obtain a copy of the License at8//9// http://www.apache.org/licenses/LICENSE-2.010//11// Unless required by applicable law or agreed to in writing,12// software distributed under the License is distributed on an13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY14// KIND, either express or implied. See the License for the15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.remote.codec.w3c;18import static org.openqa.selenium.remote.DriverCommand.ACCEPT_ALERT;19import static org.openqa.selenium.remote.DriverCommand.ACTIONS;20import static org.openqa.selenium.remote.DriverCommand.CLEAR_ACTIONS_STATE;21import static org.openqa.selenium.remote.DriverCommand.CLEAR_LOCAL_STORAGE;22import static org.openqa.selenium.remote.DriverCommand.CLEAR_SESSION_STORAGE;23import static org.openqa.selenium.remote.DriverCommand.CLICK;24import static org.openqa.selenium.remote.DriverCommand.DISMISS_ALERT;25import static org.openqa.selenium.remote.DriverCommand.DOUBLE_CLICK;26import static org.openqa.selenium.remote.DriverCommand.EXECUTE_ASYNC_SCRIPT;27import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;28import static org.openqa.selenium.remote.DriverCommand.FIND_CHILD_ELEMENT;29import static org.openqa.selenium.remote.DriverCommand.FIND_CHILD_ELEMENTS;30import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENT;31import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENTS;32import static org.openqa.selenium.remote.DriverCommand.GET_ACTIVE_ELEMENT;33import static org.openqa.selenium.remote.DriverCommand.GET_ALERT_TEXT;34import static org.openqa.selenium.remote.DriverCommand.GET_AVAILABLE_LOG_TYPES;35import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_HANDLE;36import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_POSITION;37import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_SIZE;38import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_ATTRIBUTE;39import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_LOCATION;40import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW;41import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_RECT;42import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_SIZE;43import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_ITEM;44import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_KEYS;45import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_SIZE;46import static org.openqa.selenium.remote.DriverCommand.GET_LOG;47import static org.openqa.selenium.remote.DriverCommand.GET_PAGE_SOURCE;48import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_ITEM;49import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_KEYS;50import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_SIZE;51import static org.openqa.selenium.remote.DriverCommand.GET_WINDOW_HANDLES;52import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_DISPLAYED;53import static org.openqa.selenium.remote.DriverCommand.MAXIMIZE_CURRENT_WINDOW;54import static org.openqa.selenium.remote.DriverCommand.MINIMIZE_CURRENT_WINDOW;55import static org.openqa.selenium.remote.DriverCommand.MOUSE_DOWN;56import static org.openqa.selenium.remote.DriverCommand.MOUSE_UP;57import static org.openqa.selenium.remote.DriverCommand.MOVE_TO;58import static org.openqa.selenium.remote.DriverCommand.REMOVE_LOCAL_STORAGE_ITEM;59import static org.openqa.selenium.remote.DriverCommand.REMOVE_SESSION_STORAGE_ITEM;60import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ACTIVE_ELEMENT;61import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ELEMENT;62import static org.openqa.selenium.remote.DriverCommand.SET_ALERT_VALUE;63import static org.openqa.selenium.remote.DriverCommand.SET_CURRENT_WINDOW_POSITION;64import static org.openqa.selenium.remote.DriverCommand.SET_CURRENT_WINDOW_SIZE;65import static org.openqa.selenium.remote.DriverCommand.SET_LOCAL_STORAGE_ITEM;66import static org.openqa.selenium.remote.DriverCommand.SET_SESSION_STORAGE_ITEM;67import static org.openqa.selenium.remote.DriverCommand.SET_TIMEOUT;68import static org.openqa.selenium.remote.DriverCommand.SUBMIT_ELEMENT;69import com.google.common.collect.ImmutableList;70import com.google.common.collect.ImmutableMap;71import com.google.common.io.Resources;72import org.openqa.selenium.InvalidSelectorException;73import org.openqa.selenium.WebDriverException;74import org.openqa.selenium.interactions.Interaction;75import org.openqa.selenium.interactions.KeyInput;76import org.openqa.selenium.interactions.PointerInput;77import org.openqa.selenium.interactions.Sequence;78import org.openqa.selenium.remote.RemoteWebElement;79import org.openqa.selenium.remote.codec.AbstractHttpCommandCodec;80import org.openqa.selenium.remote.internal.WebElementToJsonConverter;81import java.io.IOException;82import java.net.URL;83import java.nio.charset.StandardCharsets;84import java.time.Duration;85import java.util.ArrayList;86import java.util.Collection;87import java.util.HashMap;88import java.util.List;89import java.util.Map;90import java.util.stream.Collectors;91import java.util.stream.Stream;92/**93 * A command codec that adheres to the W3C's WebDriver wire protocol.94 *95 * @see <a href="https://w3.org/tr/webdriver">W3C WebDriver spec</a>96 */97public class W3CHttpCommandCodec extends AbstractHttpCommandCodec {98 private final PointerInput mouse = new PointerInput(PointerInput.Kind.MOUSE, "mouse");99 private final KeyInput keyboard = new KeyInput("keyboard");100 public W3CHttpCommandCodec() {101 alias(GET_ELEMENT_ATTRIBUTE, EXECUTE_SCRIPT);102 alias(GET_ELEMENT_LOCATION, GET_ELEMENT_RECT);103 alias(GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW, EXECUTE_SCRIPT);104 alias(GET_ELEMENT_SIZE, GET_ELEMENT_RECT);105 alias(IS_ELEMENT_DISPLAYED, EXECUTE_SCRIPT);106 alias(SUBMIT_ELEMENT, EXECUTE_SCRIPT);107 defineCommand(EXECUTE_SCRIPT, post("/session/:sessionId/execute/sync"));108 defineCommand(EXECUTE_ASYNC_SCRIPT, post("/session/:sessionId/execute/async"));109 alias(GET_PAGE_SOURCE, EXECUTE_SCRIPT);110 alias(CLEAR_LOCAL_STORAGE, EXECUTE_SCRIPT);111 alias(GET_LOCAL_STORAGE_KEYS, EXECUTE_SCRIPT);112 alias(SET_LOCAL_STORAGE_ITEM, EXECUTE_SCRIPT);113 alias(REMOVE_LOCAL_STORAGE_ITEM, EXECUTE_SCRIPT);114 alias(GET_LOCAL_STORAGE_ITEM, EXECUTE_SCRIPT);115 alias(GET_LOCAL_STORAGE_SIZE, EXECUTE_SCRIPT);116 alias(CLEAR_SESSION_STORAGE, EXECUTE_SCRIPT);117 alias(GET_SESSION_STORAGE_KEYS, EXECUTE_SCRIPT);118 alias(SET_SESSION_STORAGE_ITEM, EXECUTE_SCRIPT);119 alias(REMOVE_SESSION_STORAGE_ITEM, EXECUTE_SCRIPT);120 alias(GET_SESSION_STORAGE_ITEM, EXECUTE_SCRIPT);121 alias(GET_SESSION_STORAGE_SIZE, EXECUTE_SCRIPT);122 defineCommand(MAXIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/maximize"));123 defineCommand(GET_CURRENT_WINDOW_SIZE, get("/session/:sessionId/window/rect"));124 defineCommand(SET_CURRENT_WINDOW_SIZE, post("/session/:sessionId/window/rect"));125 alias(GET_CURRENT_WINDOW_POSITION, GET_CURRENT_WINDOW_SIZE);126 alias(SET_CURRENT_WINDOW_POSITION, SET_CURRENT_WINDOW_SIZE);127 defineCommand(GET_CURRENT_WINDOW_HANDLE, get("/session/:sessionId/window"));128 defineCommand(GET_WINDOW_HANDLES, get("/session/:sessionId/window/handles"));129 defineCommand(ACCEPT_ALERT, post("/session/:sessionId/alert/accept"));130 defineCommand(DISMISS_ALERT, post("/session/:sessionId/alert/dismiss"));131 defineCommand(GET_ALERT_TEXT, get("/session/:sessionId/alert/text"));132 defineCommand(SET_ALERT_VALUE, post("/session/:sessionId/alert/text"));133 defineCommand(GET_ACTIVE_ELEMENT, get("/session/:sessionId/element/active"));134 defineCommand(ACTIONS, post("/session/:sessionId/actions"));135 defineCommand(CLEAR_ACTIONS_STATE, delete("/session/:sessionId/actions"));136 defineCommand(MINIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/minimize"));137 138 139 140 141 // Emulate the old Actions API since everyone still likes to call these things.142 alias(CLICK, ACTIONS);143 alias(DOUBLE_CLICK, ACTIONS);144 alias(MOUSE_DOWN, ACTIONS);145 alias(MOUSE_UP, ACTIONS);146 alias(MOVE_TO, ACTIONS);147 defineCommand(GET_LOG, post("/session/:sessionId/se/log"));148 defineCommand(GET_AVAILABLE_LOG_TYPES, get("/session/:sessionId/se/log/types"));149 }150 @Override151 protected Map<String, ?> amendParameters(String name, Map<String, ?> parameters) {152 switch (name) {153 case CLICK:154 int button = parameters.containsKey("button") ?155 ((Number) parameters.get("button")).intValue() :156 PointerInput.MouseButton.LEFT.asArg();157 return ImmutableMap.<String, Object>builder()158 .put("actions", ImmutableList.of(159 new Sequence(mouse, 0)160 .addAction(mouse.createPointerDown(button))161 .addAction(mouse.createPointerUp(button))162 .toJson()))163 .build();164 case DOUBLE_CLICK:165 button = parameters.containsKey("button") ?166 ((Number) parameters.get("button")).intValue() :167 PointerInput.MouseButton.LEFT.asArg();168 return ImmutableMap.<String, Object>builder()169 .put("actions", ImmutableList.of(170 new Sequence(mouse, 0)171 .addAction(mouse.createPointerDown(button))172 .addAction(mouse.createPointerUp(button))173 .addAction(mouse.createPointerDown(button))174 .addAction(mouse.createPointerUp(button))175 .toJson()))176 .build();177 case FIND_CHILD_ELEMENT:178 case FIND_CHILD_ELEMENTS:179 case FIND_ELEMENT:180 case FIND_ELEMENTS:181 String using = (String) parameters.get("using");182 String value = (String) parameters.get("value");183 Map<String, Object> toReturn = new HashMap<>(parameters);184 switch (using) {185 case "class name":186 if (value.matches(".*\\s.*")) {187 throw new InvalidSelectorException("Compound class names not permitted");188 }189 toReturn.put("using", "css selector");190 toReturn.put("value", "." + cssEscape(value));191 break;192 case "id":193 toReturn.put("using", "css selector");194 toReturn.put("value", "#" + cssEscape(value));195 break;196 case "link text":197 // Do nothing198 break;199 case "name":200 toReturn.put("using", "css selector");201 toReturn.put("value", "*[name='" + value + "']");202 break;203 case "partial link text":204 // Do nothing205 break;206 case "tag name":207 toReturn.put("using", "css selector");208 toReturn.put("value", cssEscape(value));209 break;210 case "xpath":211 // Do nothing212 break;213 }214 return toReturn;215 case GET_ELEMENT_ATTRIBUTE:216 // Read the atom, wrap it, execute it.217 return executeAtom(218 "getAttribute.js",219 asElement(parameters.get("id")),220 parameters.get("name"));221 case GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW:222 return toScript(223 "var e = arguments[0]; e.scrollIntoView({behavior: 'instant', block: 'end', inline: 'nearest'}); var rect = e.getBoundingClientRect(); return {'x': rect.left, 'y': rect.top};",224 asElement(parameters.get("id")));225 case GET_PAGE_SOURCE:226 return toScript(227 "var source = document.documentElement.outerHTML; \n" +228 "if (!source) { source = new XMLSerializer().serializeToString(document); }\n" +229 "return source;");230 case CLEAR_LOCAL_STORAGE:231 return toScript("localStorage.clear()");232 case GET_LOCAL_STORAGE_KEYS:233 return toScript("return Object.keys(localStorage)");234 case SET_LOCAL_STORAGE_ITEM:235 return toScript("localStorage.setItem(arguments[0], arguments[1])",236 parameters.get("key"), parameters.get("value"));237 case REMOVE_LOCAL_STORAGE_ITEM:238 return toScript("var item = localStorage.getItem(arguments[0]); localStorage.removeItem(arguments[0]); return item",239 parameters.get("key"));240 case GET_LOCAL_STORAGE_ITEM:241 return toScript("return localStorage.getItem(arguments[0])", parameters.get("key"));242 case GET_LOCAL_STORAGE_SIZE:243 return toScript("return localStorage.length");244 case CLEAR_SESSION_STORAGE:245 return toScript("sessionStorage.clear()");246 case GET_SESSION_STORAGE_KEYS:247 return toScript("return Object.keys(sessionStorage)");248 case SET_SESSION_STORAGE_ITEM:249 return toScript("sessionStorage.setItem(arguments[0], arguments[1])",250 parameters.get("key"), parameters.get("value"));251 case REMOVE_SESSION_STORAGE_ITEM:252 return toScript("var item = sessionStorage.getItem(arguments[0]); sessionStorage.removeItem(arguments[0]); return item",253 parameters.get("key"));254 case GET_SESSION_STORAGE_ITEM:255 return toScript("return sessionStorage.getItem(arguments[0])", parameters.get("key"));256 case GET_SESSION_STORAGE_SIZE:257 return toScript("return sessionStorage.length");258 case IS_ELEMENT_DISPLAYED:259 return executeAtom("isDisplayed.js", asElement(parameters.get("id")));260 case MOUSE_DOWN:261 button = parameters.containsKey("button") ?262 ((Number) parameters.get("button")).intValue() :263 PointerInput.MouseButton.LEFT.asArg();264 Interaction mouseDown = mouse.createPointerDown(button);265 return ImmutableMap.<String, Object>builder()266 .put("actions", ImmutableList.of(new Sequence(mouse, 0).addAction(mouseDown).toJson()))267 .build();268 case MOUSE_UP:269 button = parameters.containsKey("button") ?270 ((Number) parameters.get("button")).intValue() :271 PointerInput.MouseButton.LEFT.asArg();272 Interaction mouseUp = mouse.createPointerUp(button);273 return ImmutableMap.<String, Object>builder()274 .put("actions", ImmutableList.of(new Sequence(mouse, 0).addAction(mouseUp).toJson()))275 .build();276 case MOVE_TO:277 PointerInput.Origin origin = PointerInput.Origin.pointer();278 if (parameters.containsKey("element")) {279 RemoteWebElement element = new RemoteWebElement();280 element.setId((String) parameters.get("element"));281 origin = PointerInput.Origin.fromElement(element);282 }283 int x = parameters.containsKey("xoffset") ? ((Number) parameters.get("xoffset")).intValue() : 0;284 int y = parameters.containsKey("yoffset") ? ((Number) parameters.get("yoffset")).intValue() : 0;285 Interaction mouseMove = mouse.createPointerMove(Duration.ofMillis(200), origin, x, y);286 return ImmutableMap.<String, Object>builder()287 .put("actions", ImmutableList.of(new Sequence(mouse, 0).addAction(mouseMove).toJson()))288 .build();289 case SEND_KEYS_TO_ACTIVE_ELEMENT:290 case SEND_KEYS_TO_ELEMENT:291 // When converted from JSON, this is a list, not an array292 Object rawValue = parameters.get("value");293 Stream<CharSequence> source;294 if (rawValue instanceof Collection) {295 //noinspection unchecked296 source = ((Collection<CharSequence>) rawValue).stream();297 } else {298 source = Stream.of((CharSequence[]) rawValue);299 }300 String text = source301 .flatMap(Stream::of)302 .collect(Collectors.joining());303 return ImmutableMap.<String, Object>builder()304 .putAll(305 parameters.entrySet().stream()306 .filter(e -> !"text".equals(e.getKey()))307 .filter(e -> !"value".equals(e.getKey()))308 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))309 .put("text", text)310 .put("value", stringToUtf8Array(text))311 .build();312 case SET_ALERT_VALUE:313 return ImmutableMap.<String, Object>builder()314 .put("text", parameters.get("text"))315 .put("value", stringToUtf8Array((String) parameters.get("text")))316 .build();317 case SET_TIMEOUT:318 String timeoutType = (String) parameters.get("type");319 Number duration = (Number) parameters.get("ms");320 if (timeoutType == null) {321 // Assume a local end that Knows What To Do according to the spec322 return parameters;323 }324 return ImmutableMap.<String, Object>builder()325 .putAll(326 parameters.entrySet().stream()327 .filter(e -> !timeoutType.equals(e.getKey()))328 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)))329 .put(timeoutType, duration)330 .build();331 case SUBMIT_ELEMENT:332 return toScript(333 "var form = arguments[0];\n" +334 "while (form.nodeName != \"FORM\" && form.parentNode) {\n" +335 " form = form.parentNode;\n" +336 "}\n" +337 "if (!form) { throw Error('Unable to find containing form element'); }\n" +338 "if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" +339 "var e = form.ownerDocument.createEvent('Event');\n" +340 "e.initEvent('submit', true, true);\n" +341 "if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n",342 asElement(parameters.get("id")));343 default:344 return parameters;345 }346 }347 private List<String> stringToUtf8Array(String toConvert) {348 List<String> toReturn = new ArrayList<>();349 int offset = 0;350 while (offset < toConvert.length()) {351 int next = toConvert.codePointAt(offset);352 toReturn.add(new StringBuilder().appendCodePoint(next).toString());353 offset += Character.charCount(next);354 }355 return toReturn;356 }357 private Map<String, ?> executeAtom(String atomFileName, Object... args) {358 try {359 String scriptName = "/org/openqa/selenium/remote/" + atomFileName;360 URL url = getClass().getResource(scriptName);361 String rawFunction = Resources.toString(url, StandardCharsets.UTF_8);362 String script = String.format(363 "return (%s).apply(null, arguments);",364 rawFunction);365 return toScript(script, args);366 } catch (IOException | NullPointerException e) {367 throw new WebDriverException(e);368 }369 }370 private Map<String, ?> toScript(String script, Object... args) {371 // Escape the quote marks372 script = script.replaceAll("\"", "\\\"");373 List<Object> convertedArgs = Stream.of(args).map(new WebElementToJsonConverter()).collect(374 Collectors.toList());375 return ImmutableMap.of(376 "script", script,377 "args", convertedArgs);378 }379 private Map<String, String> asElement(Object id) {380 return ImmutableMap.of("element-6066-11e4-a52e-4f735466cecf", (String) id);381 }382 private String cssEscape(String using) {383 using = using.replaceAll("([\\s'\"\\\\#.:;,!?+<>=~*^$|%&@`{}\\-\\/\\[\\]\\(\\)])", "\\\\$1");384 if (using.length() > 0 && Character.isDigit(using.charAt(0))) {385 using = "\\" + Integer.toString(30 + Integer.parseInt(using.substring(0,1))) + " " + using.substring(1);386 }387 return using;388 }389}...

Full Screen

Full Screen

Source:AbstractHttpCommandCodec.java Github

copy

Full Screen

...102import org.openqa.selenium.json.Json;103import org.openqa.selenium.net.Urls;104import org.openqa.selenium.remote.Command;105import org.openqa.selenium.remote.CommandCodec;106import org.openqa.selenium.remote.SessionId;107import org.openqa.selenium.remote.http.HttpMethod;108import org.openqa.selenium.remote.http.HttpRequest;109import java.util.HashMap;110import java.util.Map;111import java.util.concurrent.ConcurrentHashMap;112/**113 * A command codec that adheres to the W3C's WebDriver wire protocol.114 *115 * @see <a href="https://w3.org/tr/webdriver">W3C WebDriver spec</a>116 */117public abstract class AbstractHttpCommandCodec implements CommandCodec<HttpRequest> {118 private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings();119 private static final String SESSION_ID_PARAM = "sessionId";120 private final ConcurrentHashMap<String, CommandSpec> nameToSpec = new ConcurrentHashMap<>();121 private final Map<String, String> aliases = new HashMap<>();122 private final Json json = new Json();123 public AbstractHttpCommandCodec() {124 defineCommand(STATUS, get("/status"));125 defineCommand(GET_ALL_SESSIONS, get("/sessions"));126 defineCommand(NEW_SESSION, post("/session"));127 defineCommand(GET_CAPABILITIES, get("/session/:sessionId"));128 defineCommand(QUIT, delete("/session/:sessionId"));129 defineCommand(GET_SESSION_LOGS, post("/logs"));130 defineCommand(GET_LOG, post("/session/:sessionId/log"));131 defineCommand(GET_AVAILABLE_LOG_TYPES, get("/session/:sessionId/log/types"));132 defineCommand(SWITCH_TO_FRAME, post("/session/:sessionId/frame"));133 defineCommand(SWITCH_TO_PARENT_FRAME, post("/session/:sessionId/frame/parent"));134 defineCommand(CLOSE, delete("/session/:sessionId/window"));135 defineCommand(SWITCH_TO_WINDOW, post("/session/:sessionId/window"));136 defineCommand(SWITCH_TO_NEW_WINDOW, post("/session/:sessionId/window/new"));137 defineCommand(FULLSCREEN_CURRENT_WINDOW, post("/session/:sessionId/window/fullscreen"));138 defineCommand(GET_CURRENT_URL, get("/session/:sessionId/url"));139 defineCommand(GET, post("/session/:sessionId/url"));140 defineCommand(GO_BACK, post("/session/:sessionId/back"));141 defineCommand(GO_FORWARD, post("/session/:sessionId/forward"));142 defineCommand(REFRESH, post("/session/:sessionId/refresh"));143 defineCommand(SET_ALERT_CREDENTIALS, post("/session/:sessionId/alert/credentials"));144 defineCommand(UPLOAD_FILE, post("/session/:sessionId/file"));145 defineCommand(SCREENSHOT, get("/session/:sessionId/screenshot"));146 defineCommand(ELEMENT_SCREENSHOT, get("/session/:sessionId/element/:id/screenshot"));147 defineCommand(FULL_SCREENSHOT, get("/session/:sessionId/fullPageScreenshot"));148 149 150 defineCommand(GET_TITLE, get("/session/:sessionId/title"));151 defineCommand(FIND_ELEMENT, post("/session/:sessionId/element"));152 defineCommand(FIND_ELEMENTS, post("/session/:sessionId/elements"));153 defineCommand(GET_ELEMENT_PROPERTY, get("/session/:sessionId/element/:id/property/:name"));154 defineCommand(CLICK_ELEMENT, post("/session/:sessionId/element/:id/click"));155 defineCommand(CLEAR_ELEMENT, post("/session/:sessionId/element/:id/clear"));156 defineCommand(157 GET_ELEMENT_VALUE_OF_CSS_PROPERTY,158 get("/session/:sessionId/element/:id/css/:propertyName"));159 defineCommand(FIND_CHILD_ELEMENT, post("/session/:sessionId/element/:id/element"));160 defineCommand(FIND_CHILD_ELEMENTS, post("/session/:sessionId/element/:id/elements"));161 defineCommand(IS_ELEMENT_ENABLED, get("/session/:sessionId/element/:id/enabled"));162 defineCommand(ELEMENT_EQUALS, get("/session/:sessionId/element/:id/equals/:other"));163 defineCommand(GET_ELEMENT_RECT, get("/session/:sessionId/element/:id/rect"));164 defineCommand(GET_ELEMENT_LOCATION, get("/session/:sessionId/element/:id/location"));165 defineCommand(GET_ELEMENT_TAG_NAME, get("/session/:sessionId/element/:id/name"));166 defineCommand(IS_ELEMENT_SELECTED, get("/session/:sessionId/element/:id/selected"));167 defineCommand(GET_ELEMENT_SIZE, get("/session/:sessionId/element/:id/size"));168 defineCommand(GET_ELEMENT_TEXT, get("/session/:sessionId/element/:id/text"));169 defineCommand(SEND_KEYS_TO_ELEMENT, post("/session/:sessionId/element/:id/value"));170 defineCommand(GET_ALL_COOKIES, get("/session/:sessionId/cookie"));171 defineCommand(GET_COOKIE, get("/session/:sessionId/cookie/:name"));172 defineCommand(ADD_COOKIE, post("/session/:sessionId/cookie"));173 defineCommand(DELETE_ALL_COOKIES, delete("/session/:sessionId/cookie"));174 defineCommand(DELETE_COOKIE, delete("/session/:sessionId/cookie/:name"));175 defineCommand(SET_TIMEOUT, post("/session/:sessionId/timeouts"));176 defineCommand(SET_SCRIPT_TIMEOUT, post("/session/:sessionId/timeouts/async_script"));177 defineCommand(IMPLICITLY_WAIT, post("/session/:sessionId/timeouts/implicit_wait"));178 defineCommand(GET_APP_CACHE_STATUS, get("/session/:sessionId/application_cache/status"));179 defineCommand(IS_BROWSER_ONLINE, get("/session/:sessionId/browser_connection"));180 defineCommand(SET_BROWSER_ONLINE, post("/session/:sessionId/browser_connection"));181 defineCommand(GET_LOCATION, get("/session/:sessionId/location"));182 defineCommand(SET_LOCATION, post("/session/:sessionId/location"));183 defineCommand(GET_SCREEN_ORIENTATION, get("/session/:sessionId/orientation"));184 defineCommand(SET_SCREEN_ORIENTATION, post("/session/:sessionId/orientation"));185 defineCommand(GET_SCREEN_ROTATION, get("/session/:sessionId/rotation"));186 defineCommand(SET_SCREEN_ROTATION, post("/session/:sessionId/rotation"));187 defineCommand(IME_GET_AVAILABLE_ENGINES, get("/session/:sessionId/ime/available_engines"));188 defineCommand(IME_GET_ACTIVE_ENGINE, get("/session/:sessionId/ime/active_engine"));189 defineCommand(IME_IS_ACTIVATED, get("/session/:sessionId/ime/activated"));190 defineCommand(IME_DEACTIVATE, post("/session/:sessionId/ime/deactivate"));191 defineCommand(IME_ACTIVATE_ENGINE, post("/session/:sessionId/ime/activate"));192 // Mobile Spec193 defineCommand(GET_NETWORK_CONNECTION, get("/session/:sessionId/network_connection"));194 defineCommand(SET_NETWORK_CONNECTION, post("/session/:sessionId/network_connection"));195 defineCommand(SWITCH_TO_CONTEXT, post("/session/:sessionId/context"));196 defineCommand(GET_CURRENT_CONTEXT_HANDLE, get("/session/:sessionId/context"));197 defineCommand(GET_CONTEXT_HANDLES, get("/session/:sessionId/contexts"));198 }199 @Override200 public HttpRequest encode(Command command) {201 String name = aliases.getOrDefault(command.getName(), command.getName());202 CommandSpec spec = nameToSpec.get(name);203 if (spec == null) {204 throw new UnsupportedCommandException(command.getName());205 }206 Map<String, ?> parameters = amendParameters(command.getName(), command.getParameters());207 String uri = buildUri(name, command.getSessionId(), parameters, spec);208 HttpRequest request = new HttpRequest(spec.method, uri);209 if (HttpMethod.POST == spec.method) {210 String content = json.toJson(parameters);211 byte[] data = content.getBytes(UTF_8);212 request.setHeader(CONTENT_LENGTH, String.valueOf(data.length));213 request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());214 request.setContent(bytes(data));215 }216 if (HttpMethod.GET == spec.method) {217 request.setHeader(CACHE_CONTROL, "no-cache");218 }219 return request;220 }221 protected abstract Map<String,?> amendParameters(String name, Map<String, ?> parameters);222 @Override223 public Command decode(final HttpRequest encodedCommand) {224 final String path = Strings.isNullOrEmpty(encodedCommand.getUri())225 ? "/" : encodedCommand.getUri();226 final ImmutableList<String> parts = ImmutableList.copyOf(PATH_SPLITTER.split(path));227 int minPathLength = Integer.MAX_VALUE;228 CommandSpec spec = null;229 String name = null;230 for (Map.Entry<String, CommandSpec> nameValue : nameToSpec.entrySet()) {231 if ((nameValue.getValue().pathSegments.size() < minPathLength)232 && nameValue.getValue().isFor(encodedCommand.getMethod(), parts)) {233 name = nameValue.getKey();234 spec = nameValue.getValue();235 }236 }237 if (name == null) {238 throw new UnsupportedCommandException(239 encodedCommand.getMethod() + " " + encodedCommand.getUri());240 }241 Map<String, Object> parameters = new HashMap<>();242 spec.parsePathParameters(parts, parameters);243 String content = string(encodedCommand);244 if (!content.isEmpty()) {245 Map<String, Object> tmp = json.toType(content, MAP_TYPE);246 parameters.putAll(tmp);247 }248 SessionId sessionId = null;249 if (parameters.containsKey(SESSION_ID_PARAM)) {250 String id = (String) parameters.remove(SESSION_ID_PARAM);251 if (id != null) {252 sessionId = new SessionId(id);253 }254 }255 return new Command(sessionId, name, parameters);256 }257 /**258 * Defines a new command mapping.259 *260 * @param name The command name.261 * @param method The HTTP method to use for the command.262 * @param pathPattern The URI path pattern for the command. When encoding a command, each263 * path segment prefixed with a ":" will be replaced with the corresponding parameter264 * from the encoded command.265 */266 @Override267 public void defineCommand(String name, HttpMethod method, String pathPattern) {268 defineCommand(name, new CommandSpec(method, pathPattern));269 }270 @Override271 public void alias(String commandName, String isAnAliasFor) {272 aliases.put(commandName, isAnAliasFor);273 }274 protected void defineCommand(String name, CommandSpec spec) {275 checkNotNull(name, "null name");276 nameToSpec.put(name, spec);277 }278 protected static CommandSpec delete(String path) {279 return new CommandSpec(HttpMethod.DELETE, path);280 }281 protected static CommandSpec get(String path) {282 return new CommandSpec(HttpMethod.GET, path);283 }284 protected static CommandSpec post(String path) {285 return new CommandSpec(HttpMethod.POST, path);286 }287 private String buildUri(288 String commandName,289 SessionId sessionId,290 Map<String, ?> parameters,291 CommandSpec spec) {292 StringBuilder builder = new StringBuilder();293 for (String part : spec.pathSegments) {294 if (part.isEmpty()) {295 continue;296 }297 builder.append("/");298 if (part.startsWith(":")) {299 builder.append(getParameter(part.substring(1), commandName, sessionId, parameters));300 } else {301 builder.append(part);302 }303 }304 return builder.toString();305 }306 private String getParameter(307 String parameterName,308 String commandName,309 SessionId sessionId,310 Map<String, ?> parameters) {311 if ("sessionId".equals(parameterName)) {312 checkArgument(sessionId != null, "Session ID may not be null for command %s", commandName);313 return sessionId.toString();314 }315 Object value = parameters.get(parameterName);316 checkArgument(value != null,317 "Missing required parameter \"%s\" for command %s", parameterName, commandName);318 return Urls.urlEncode(String.valueOf(value));319 }320 protected static class CommandSpec {321 private final HttpMethod method;322 private final String path;323 private final ImmutableList<String> pathSegments;...

Full Screen

Full Screen

Source:JsonHttpCommandCodec.java Github

copy

Full Screen

1// Licensed to the Software Freedom Conservancy (SFC) under one2// or more contributor license agreements. See the NOTICE file3// distributed with this work for additional information4// regarding copyright ownership. The SFC licenses this file5// to you under the Apache License, Version 2.0 (the6// "License"); you may not use this file except in compliance7// with the License. You may obtain a copy of the License at8//9// http://www.apache.org/licenses/LICENSE-2.010//11// Unless required by applicable law or agreed to in writing,12// software distributed under the License is distributed on an13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY14// KIND, either express or implied. See the License for the15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.remote.http;18import static org.openqa.selenium.remote.DriverCommand.ACCEPT_ALERT;19import static org.openqa.selenium.remote.DriverCommand.CLEAR_LOCAL_STORAGE;20import static org.openqa.selenium.remote.DriverCommand.CLEAR_SESSION_STORAGE;21import static org.openqa.selenium.remote.DriverCommand.CLICK;22import static org.openqa.selenium.remote.DriverCommand.DISMISS_ALERT;23import static org.openqa.selenium.remote.DriverCommand.DOUBLE_CLICK;24import static org.openqa.selenium.remote.DriverCommand.EXECUTE_ASYNC_SCRIPT;25import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;26import static org.openqa.selenium.remote.DriverCommand.GET_ACTIVE_ELEMENT;27import static org.openqa.selenium.remote.DriverCommand.GET_ALERT_TEXT;28import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_HANDLE;29import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_POSITION;30import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_WINDOW_SIZE;31import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_ATTRIBUTE;32import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW;33import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_ITEM;34import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_KEYS;35import static org.openqa.selenium.remote.DriverCommand.GET_LOCAL_STORAGE_SIZE;36import static org.openqa.selenium.remote.DriverCommand.GET_PAGE_SOURCE;37import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_ITEM;38import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_KEYS;39import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_STORAGE_SIZE;40import static org.openqa.selenium.remote.DriverCommand.GET_WINDOW_HANDLES;41import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_DISPLAYED;42import static org.openqa.selenium.remote.DriverCommand.MAXIMIZE_CURRENT_WINDOW;43import static org.openqa.selenium.remote.DriverCommand.MOUSE_DOWN;44import static org.openqa.selenium.remote.DriverCommand.MOUSE_UP;45import static org.openqa.selenium.remote.DriverCommand.MOVE_TO;46import static org.openqa.selenium.remote.DriverCommand.REMOVE_LOCAL_STORAGE_ITEM;47import static org.openqa.selenium.remote.DriverCommand.REMOVE_SESSION_STORAGE_ITEM;48import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ACTIVE_ELEMENT;49import static org.openqa.selenium.remote.DriverCommand.SET_ALERT_VALUE;50import static org.openqa.selenium.remote.DriverCommand.SET_CURRENT_WINDOW_POSITION;51import static org.openqa.selenium.remote.DriverCommand.SET_CURRENT_WINDOW_SIZE;52import static org.openqa.selenium.remote.DriverCommand.SET_LOCAL_STORAGE_ITEM;53import static org.openqa.selenium.remote.DriverCommand.SET_SESSION_STORAGE_ITEM;54import static org.openqa.selenium.remote.DriverCommand.SUBMIT_ELEMENT;55import static org.openqa.selenium.remote.DriverCommand.TOUCH_DOUBLE_TAP;56import static org.openqa.selenium.remote.DriverCommand.TOUCH_DOWN;57import static org.openqa.selenium.remote.DriverCommand.TOUCH_FLICK;58import static org.openqa.selenium.remote.DriverCommand.TOUCH_LONG_PRESS;59import static org.openqa.selenium.remote.DriverCommand.TOUCH_MOVE;60import static org.openqa.selenium.remote.DriverCommand.TOUCH_SCROLL;61import static org.openqa.selenium.remote.DriverCommand.TOUCH_SINGLE_TAP;62import static org.openqa.selenium.remote.DriverCommand.TOUCH_UP;63import com.google.common.collect.ImmutableMap;64import org.openqa.selenium.InvalidArgumentException;65import org.openqa.selenium.remote.DriverCommand;66import java.util.Map;67/**68 * A command codec that adheres to the Selenium project's JSON/HTTP wire protocol.69 *70 * @see <a href="https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol">71 * JSON wire protocol</a>72 */73public class JsonHttpCommandCodec extends AbstractHttpCommandCodec {74 public JsonHttpCommandCodec() {75 defineCommand(GET_ELEMENT_ATTRIBUTE, get("/session/:sessionId/element/:id/attribute/:name"));76 defineCommand(GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW, get("/session/:sessionId/element/:id/location_in_view"));77 defineCommand(IS_ELEMENT_DISPLAYED, get("/session/:sessionId/element/:id/displayed"));78 defineCommand(SUBMIT_ELEMENT, post("/session/:sessionId/element/:id/submit"));79 defineCommand(EXECUTE_SCRIPT, post("/session/:sessionId/execute"));80 defineCommand(EXECUTE_ASYNC_SCRIPT, post("/session/:sessionId/execute_async"));81 defineCommand(GET_PAGE_SOURCE, get("/session/:sessionId/source"));82 defineCommand(MAXIMIZE_CURRENT_WINDOW, post("/session/:sessionId/window/:windowHandle/maximize"));83 defineCommand(GET_CURRENT_WINDOW_POSITION, get("/session/:sessionId/window/:windowHandle/position"));84 defineCommand(SET_CURRENT_WINDOW_POSITION, post("/session/:sessionId/window/:windowHandle/position"));85 defineCommand(GET_CURRENT_WINDOW_SIZE, get("/session/:sessionId/window/:windowHandle/size"));86 defineCommand(SET_CURRENT_WINDOW_SIZE, post("/session/:sessionId/window/:windowHandle/size"));87 defineCommand(GET_CURRENT_WINDOW_HANDLE, get("/session/:sessionId/window_handle"));88 defineCommand(GET_WINDOW_HANDLES, get("/session/:sessionId/window_handles"));89 defineCommand(ACCEPT_ALERT, post("/session/:sessionId/accept_alert"));90 defineCommand(DISMISS_ALERT, post("/session/:sessionId/dismiss_alert"));91 defineCommand(GET_ALERT_TEXT, get("/session/:sessionId/alert_text"));92 defineCommand(SET_ALERT_VALUE, post("/session/:sessionId/alert_text"));93 defineCommand(GET_ACTIVE_ELEMENT, post("/session/:sessionId/element/active"));94 defineCommand(CLEAR_LOCAL_STORAGE, delete("/session/:sessionId/local_storage"));95 defineCommand(GET_LOCAL_STORAGE_KEYS, get("/session/:sessionId/local_storage"));96 defineCommand(SET_LOCAL_STORAGE_ITEM, post("/session/:sessionId/local_storage"));97 defineCommand(REMOVE_LOCAL_STORAGE_ITEM, delete("/session/:sessionId/local_storage/key/:key"));98 defineCommand(GET_LOCAL_STORAGE_ITEM, get("/session/:sessionId/local_storage/key/:key"));99 defineCommand(GET_LOCAL_STORAGE_SIZE, get("/session/:sessionId/local_storage/size"));100 defineCommand(CLEAR_SESSION_STORAGE, delete("/session/:sessionId/session_storage"));101 defineCommand(GET_SESSION_STORAGE_KEYS, get("/session/:sessionId/session_storage"));102 defineCommand(SET_SESSION_STORAGE_ITEM, post("/session/:sessionId/session_storage"));103 defineCommand(REMOVE_SESSION_STORAGE_ITEM, delete("/session/:sessionId/session_storage/key/:key"));104 defineCommand(GET_SESSION_STORAGE_ITEM, get("/session/:sessionId/session_storage/key/:key"));105 defineCommand(GET_SESSION_STORAGE_SIZE, get("/session/:sessionId/session_storage/size"));106 // Interactions-related commands.107 defineCommand(MOUSE_DOWN, post("/session/:sessionId/buttondown"));108 defineCommand(MOUSE_UP, post("/session/:sessionId/buttonup"));109 defineCommand(CLICK, post("/session/:sessionId/click"));110 defineCommand(DOUBLE_CLICK, post("/session/:sessionId/doubleclick"));111 defineCommand(MOVE_TO, post("/session/:sessionId/moveto"));112 defineCommand(SEND_KEYS_TO_ACTIVE_ELEMENT, post("/session/:sessionId/keys"));113 defineCommand(TOUCH_SINGLE_TAP, post("/session/:sessionId/touch/click"));114 defineCommand(TOUCH_DOUBLE_TAP, post("/session/:sessionId/touch/doubleclick"));115 defineCommand(TOUCH_DOWN, post("/session/:sessionId/touch/down"));116 defineCommand(TOUCH_FLICK, post("/session/:sessionId/touch/flick"));117 defineCommand(TOUCH_LONG_PRESS, post("/session/:sessionId/touch/longclick"));118 defineCommand(TOUCH_MOVE, post("/session/:sessionId/touch/move"));119 defineCommand(TOUCH_SCROLL, post("/session/:sessionId/touch/scroll"));120 defineCommand(TOUCH_UP, post("/session/:sessionId/touch/up"));121 }122 @Override123 protected Map<String, ?> amendParameters(String name, Map<String, ?> parameters) {124 switch (name) {125 case DriverCommand.GET_CURRENT_WINDOW_SIZE:126 case DriverCommand.MAXIMIZE_CURRENT_WINDOW:127 case DriverCommand.SET_CURRENT_WINDOW_SIZE:128 case DriverCommand.SET_CURRENT_WINDOW_POSITION:129 return ImmutableMap.<String, Object>builder()130 .putAll(parameters)131 .put("windowHandle", "current")132 .put("handle", "current")133 .build();134 case DriverCommand.SET_TIMEOUT:135 if (parameters.size() != 1) {136 throw new InvalidArgumentException(137 "The JSON wire protocol only supports setting one time out at a time");138 }139 Map.Entry<String, ?> entry = parameters.entrySet().iterator().next();140 String type = entry.getKey();141 if ("pageLoad".equals(type)) {142 type = "page load";143 }144 return ImmutableMap.of("type", type, "ms", entry.getValue());145 case DriverCommand.SWITCH_TO_WINDOW:146 return ImmutableMap.<String, Object>builder()147 .put("name", parameters.get("handle"))148 .build();149 default:150 return parameters;151 }152 }153}...

Full Screen

Full Screen

SessionId

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.SessionId;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.remote.RemoteWebDriver;4import java.net.URL;5import org.openqa.selenium.WebDriverException;6import java.io.IOException;7import java.io.File;8import java.io.FileInputStream;9import java.util.Properties;10import org.openqa.selenium.WebDriver;11import org.openqa.selenium.By;12import org.openqa.selenium.WebElement;13import org.openqa.selenium.Keys;14import java.util.concurrent.TimeUnit;15import org.openqa.selenium.support.ui.ExpectedConditions;16import org.openqa.selenium.support.ui.WebDriverWait;17import org.openqa.selenium.TakesScreenshot;18import org.openqa.selenium.OutputType;19import java.io.File;20import java.io.IOException;21import java.text.SimpleDateFormat;22import java.util.Date;23import org.junit.Assert;24import org.junit.Test;25import org.junit.Before;26import org.junit.After;27import org.junit.BeforeClass;28import org.junit.AfterClass;

Full Screen

Full Screen

SessionId

Using AI Code Generation

copy

Full Screen

1package com.test;2import java.util.concurrent.TimeUnit;3import org.openqa.selenium.By;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.firefox.FirefoxDriver;8import org.openqa.selenium.ie.InternetExplorerDriver;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.openqa.selenium.remote.RemoteWebDriver;11import org.openqa.selenium.remote.SessionId;12import org.openqa.selenium.support.ui.ExpectedConditions;13import org.openqa.selenium.support.ui.WebDriverWait;14public class SeleniumGridExample {15public static void main(String[] args) throws InterruptedException {16WebDriver driver = null;17System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");18driver = new ChromeDriver();19System.out.println("Page title is: " + driver.getTitle());

Full Screen

Full Screen

SessionId

Using AI Code Generation

copy

Full Screen

1DesiredCapabilities capabilities = DesiredCapabilities.chrome();2capabilities.setCapability("goog:loggingPrefs", ImmutableMap.of("performance", "ALL"));3WebDriver driver = new ChromeDriver(capabilities);4driver.manage().window().maximize();5SessionId sessionId = ((ChromeDriver) driver).getSessionId();6List<LogEntry> performanceLogs = driver.manage().logs().get("performance").filter(Level.ALL);7FileWriter fileWriter = new FileWriter("C:\\Users\\shubham\\Desktop\\performanceLogs.json");8for (LogEntry entry : performanceLogs) {9 fileWriter.write(entry.getMessage() + "10");11}12fileWriter.close();13driver.quit();14I have tried with the latest version of ChromeDriver (86.0.4240.22) and Selenium (3.141.59) but still I am facing the same issue. I am using Windows 10 and Chrome version is 86.0.4240.75 (Official Build) (64-bit). I am using the following code to get the performance logs:15DesiredCapabilities capabilities = DesiredCapabilities.chrome();16capabilities.setCapability("goog:

Full Screen

Full Screen

SessionId

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.SessionId;2import org.openqa.selenium.remote.RemoteWebDriver;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.remote.RemoteWebElement;5import org.openqa.selenium.By;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.chrome.ChromeDriver;9import org.openqa.selenium.chrome.ChromeOptions;10import org.openqa.selenium.firefox.FirefoxDriver;11import org.openqa.selenium.firefox.FirefoxOptions;12import org.openqa.selenium.firefox.FirefoxProfile;13import org.openqa.selenium.firefox.FirefoxDriverLogLevel;14import org.openqa.selenium.firefox.FirefoxDriverService;15import org.openqa.selenium.firefox.FirefoxDriverInfo;16import org.openqa.selenium.firefox.FirefoxDriverInfoBuilder;17import org.openqa.selenium.firefox.FirefoxDriverInfoProvider;18import org.openqa.selenium.firefox.FirefoxDriverProvider;19import org.openqa.selenium.firefox.FirefoxDriverProviderService;20import org.openqa.selenium.firefox.FirefoxDriverProviderInfo;21import org.openqa.selenium.firefox.FirefoxDriverProviderInfoBuilder;22import org.openqa.selenium.firefox.FirefoxDriverProviderInfoProvider;23import org.openqa.selenium.firefox.FirefoxDriverProviderService;24import org.openqa.selenium.firefox.FirefoxDriverServiceBuilder;25import org.openqa.selenium.firefox.FirefoxOptions;26import org.openqa.selenium.firefox.FirefoxProfile;27import org.openqa.selenium.firefox.FirefoxDriverLogLevel;28import org.openqa.selenium.firefox.FirefoxDriverService;29import org.openqa.selenium.firefox.FirefoxDriverInfo;30import org.openqa.selenium.firefox.FirefoxDriverInfoBuilder;31import org.openqa.selenium.firefox.FirefoxDriverInfoProvider;32import org.openqa.selenium.firefox.FirefoxDriverProvider;33import org.openqa.selenium.firefox.FirefoxDriverProviderService;34import org.openqa.selenium.firefox.FirefoxDriverProviderInfo;35import org.openqa.selenium.firefox.FirefoxDriverProviderInfoBuilder;36import org.openqa.selenium.firefox.FirefoxDriverProviderInfoProvider;37import org.openqa.selenium.firefox.FirefoxDriverProviderService;38import org.openqa.selenium.firefox.FirefoxDriverServiceBuilder;39import org.openqa.selenium.firefox.FirefoxOptions;40import org.openqa.selenium.firefox.FirefoxProfile;41import org.openqa.selenium.firefox.FirefoxDriverLogLevel;42import org.openqa.selenium.firefox.FirefoxDriverService;43import org.openqa.selenium.firefox.FirefoxDriverInfo;44import org.openqa.selenium.firefox.FirefoxDriverInfoBuilder;45import org.openqa.selenium.firefox.FirefoxDriverInfoProvider;46import org.openqa.selenium.firefox.FirefoxDriverProvider;47import org.openqa.selenium.firefox.FirefoxDriver

Full Screen

Full Screen

SessionId

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.SessionId;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.remote.RemoteWebDriver;4import org.openqa.selenium.remote.DesiredCapabilities;5import java.net.URL;6import org.openqa.selenium.firefox.FirefoxDriver;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.ie.InternetExplorerDriver;9import org.openqa.selenium.edge.EdgeDriver;10import org.openqa.selenium.safari.SafariDriver;11import org.openqa.selenium.opera.OperaDriver;12import org.openqa.selenium.phantomjs.PhantomJSDriver;13import io.appium.java_client.android.AndroidDriver;14import io.appium.java_client.ios.IOSDriver;15import org.openqa.selenium.remote.RemoteTouchScreen;16import org.openqa.selenium.TouchScreen;17import org.openqa.selenium.remote.RemoteWebElement;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.remote.RemoteKeyboard;20import org.openqa.selenium.Keyboard;21import org.openqa.selenium.remote.RemoteMouse;22import org.openqa.selenium.Mouse;23import org.openqa.selenium

Full Screen

Full Screen
copy
1class DB {2 private String dummy;34 public DB(DB one) {5 this.dummy = one.dummy; 6 }7}8
Full Screen
copy
1<dependency>2 <groupId>com.thoughtworks.xstream</groupId>3 <artifactId>xstream</artifactId>4 <version>1.3.1</version> 5</dependency>6
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 SessionId

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