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

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

Source:W3CHttpCommandCodec.java Github

copy

Full Screen

...14// 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()))...

Full Screen

Full Screen

Source:AbstractHttpCommandCodec.java Github

copy

Full Screen

...22import static com.google.common.net.HttpHeaders.CONTENT_TYPE;23import static com.google.common.net.MediaType.JSON_UTF_8;24import static java.nio.charset.StandardCharsets.UTF_8;25import static org.openqa.selenium.json.Json.MAP_TYPE;26import static org.openqa.selenium.remote.DriverCommand.ADD_COOKIE;27import static org.openqa.selenium.remote.DriverCommand.CLEAR_ELEMENT;28import static org.openqa.selenium.remote.DriverCommand.CLICK_ELEMENT;29import static org.openqa.selenium.remote.DriverCommand.CLOSE;30import static org.openqa.selenium.remote.DriverCommand.DELETE_ALL_COOKIES;31import static org.openqa.selenium.remote.DriverCommand.DELETE_COOKIE;32import static org.openqa.selenium.remote.DriverCommand.ELEMENT_EQUALS;33import static org.openqa.selenium.remote.DriverCommand.ELEMENT_SCREENSHOT;34import static org.openqa.selenium.remote.DriverCommand.FIND_CHILD_ELEMENT;35import static org.openqa.selenium.remote.DriverCommand.FIND_CHILD_ELEMENTS;36import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENT;37import static org.openqa.selenium.remote.DriverCommand.FIND_ELEMENTS;38import static org.openqa.selenium.remote.DriverCommand.FULLSCREEN_CURRENT_WINDOW;39import static org.openqa.selenium.remote.DriverCommand.GET;40import static org.openqa.selenium.remote.DriverCommand.GET_ALL_COOKIES;41import static org.openqa.selenium.remote.DriverCommand.GET_ALL_SESSIONS;42import static org.openqa.selenium.remote.DriverCommand.GET_APP_CACHE_STATUS;43import static org.openqa.selenium.remote.DriverCommand.GET_AVAILABLE_LOG_TYPES;44import static org.openqa.selenium.remote.DriverCommand.GET_CAPABILITIES;45import static org.openqa.selenium.remote.DriverCommand.GET_CONTEXT_HANDLES;46import static org.openqa.selenium.remote.DriverCommand.GET_COOKIE;47import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_CONTEXT_HANDLE;48import static org.openqa.selenium.remote.DriverCommand.GET_CURRENT_URL;49import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_LOCATION;50import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_PROPERTY;51import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_RECT;52import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_SIZE;53import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_TAG_NAME;54import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_TEXT;55import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_VALUE_OF_CSS_PROPERTY;56import static org.openqa.selenium.remote.DriverCommand.GET_LOCATION;57import static org.openqa.selenium.remote.DriverCommand.GET_LOG;58import static org.openqa.selenium.remote.DriverCommand.GET_NETWORK_CONNECTION;59import static org.openqa.selenium.remote.DriverCommand.GET_SCREEN_ORIENTATION;60import static org.openqa.selenium.remote.DriverCommand.GET_SCREEN_ROTATION;61import static org.openqa.selenium.remote.DriverCommand.GET_SESSION_LOGS;62import static org.openqa.selenium.remote.DriverCommand.GET_TITLE;63import static org.openqa.selenium.remote.DriverCommand.GO_BACK;64import static org.openqa.selenium.remote.DriverCommand.GO_FORWARD;65import static org.openqa.selenium.remote.DriverCommand.IME_ACTIVATE_ENGINE;66import static org.openqa.selenium.remote.DriverCommand.IME_DEACTIVATE;67import static org.openqa.selenium.remote.DriverCommand.IME_GET_ACTIVE_ENGINE;68import static org.openqa.selenium.remote.DriverCommand.IME_GET_AVAILABLE_ENGINES;69import static org.openqa.selenium.remote.DriverCommand.IME_IS_ACTIVATED;70import static org.openqa.selenium.remote.DriverCommand.IMPLICITLY_WAIT;71import static org.openqa.selenium.remote.DriverCommand.IS_BROWSER_ONLINE;72import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_ENABLED;73import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_SELECTED;74import static org.openqa.selenium.remote.DriverCommand.NEW_SESSION;75import static org.openqa.selenium.remote.DriverCommand.QUIT;76import static org.openqa.selenium.remote.DriverCommand.REFRESH;77import static org.openqa.selenium.remote.DriverCommand.SCREENSHOT;78import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ELEMENT;79import static org.openqa.selenium.remote.DriverCommand.SET_ALERT_CREDENTIALS;80import static org.openqa.selenium.remote.DriverCommand.SET_BROWSER_ONLINE;81import static org.openqa.selenium.remote.DriverCommand.SET_LOCATION;82import static org.openqa.selenium.remote.DriverCommand.SET_NETWORK_CONNECTION;83import static org.openqa.selenium.remote.DriverCommand.SET_SCREEN_ORIENTATION;84import static org.openqa.selenium.remote.DriverCommand.SET_SCREEN_ROTATION;85import static org.openqa.selenium.remote.DriverCommand.SET_SCRIPT_TIMEOUT;86import static org.openqa.selenium.remote.DriverCommand.SET_TIMEOUT;87import static org.openqa.selenium.remote.DriverCommand.STATUS;88import static org.openqa.selenium.remote.DriverCommand.SWITCH_TO_CONTEXT;89import static org.openqa.selenium.remote.DriverCommand.SWITCH_TO_FRAME;90import static org.openqa.selenium.remote.DriverCommand.SWITCH_TO_PARENT_FRAME;91import static org.openqa.selenium.remote.DriverCommand.SWITCH_TO_WINDOW;92import static org.openqa.selenium.remote.DriverCommand.UPLOAD_FILE;93import static org.openqa.selenium.remote.DriverCommand.NETWORK_LOG_CAPTURE;94import static org.openqa.selenium.remote.DriverCommand.GET_MONITOR_STATS;95import com.google.common.base.Objects;96import com.google.common.base.Splitter;97import com.google.common.base.Strings;98import com.google.common.collect.ImmutableList;99import org.openqa.selenium.UnsupportedCommandException;100import org.openqa.selenium.json.Json;101import org.openqa.selenium.net.Urls;102import org.openqa.selenium.remote.Command;103import org.openqa.selenium.remote.CommandCodec;104import org.openqa.selenium.remote.SessionId;105import java.util.HashMap;106import java.util.Map;107import java.util.concurrent.ConcurrentHashMap;108/**109 * A command codec that adheres to the W3C's WebDriver wire protocol.110 *111 * @see <a href="https://w3.org/tr/webdriver">W3C WebDriver spec</a>112 */113public abstract class AbstractHttpCommandCodec implements CommandCodec<HttpRequest> {114 private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings();115 private static final String SESSION_ID_PARAM = "sessionId";116 private final ConcurrentHashMap<String, CommandSpec> nameToSpec = new ConcurrentHashMap<>();117 private final Map<String, String> aliases = new HashMap<>();118 private final Json json = new Json();119 public AbstractHttpCommandCodec() {120 defineCommand(STATUS, get("/status"));121 defineCommand(GET_ALL_SESSIONS, get("/sessions"));122 defineCommand(NEW_SESSION, post("/session"));123 defineCommand(GET_CAPABILITIES, get("/session/:sessionId"));124 defineCommand(QUIT, delete("/session/:sessionId"));125 defineCommand(GET_SESSION_LOGS, post("/logs"));126 defineCommand(GET_LOG, post("/session/:sessionId/log"));127 defineCommand(GET_AVAILABLE_LOG_TYPES, get("/session/:sessionId/log/types"));128 defineCommand(SWITCH_TO_FRAME, post("/session/:sessionId/frame"));129 defineCommand(SWITCH_TO_PARENT_FRAME, post("/session/:sessionId/frame/parent"));130 defineCommand(CLOSE, delete("/session/:sessionId/window"));131 defineCommand(SWITCH_TO_WINDOW, post("/session/:sessionId/window"));132 defineCommand(FULLSCREEN_CURRENT_WINDOW, post("/session/:sessionId/window/fullscreen"));133 defineCommand(GET_CURRENT_URL, get("/session/:sessionId/url"));134 defineCommand(GET, post("/session/:sessionId/url"));135 defineCommand(GO_BACK, post("/session/:sessionId/back"));136 defineCommand(GO_FORWARD, post("/session/:sessionId/forward"));137 defineCommand(REFRESH, post("/session/:sessionId/refresh"));138 defineCommand(SET_ALERT_CREDENTIALS, post("/session/:sessionId/alert/credentials"));139 defineCommand(UPLOAD_FILE, post("/session/:sessionId/file"));140 defineCommand(SCREENSHOT, get("/session/:sessionId/screenshot"));141 defineCommand(ELEMENT_SCREENSHOT, get("/session/:sessionId/element/:id/screenshot"));142 defineCommand(GET_TITLE, get("/session/:sessionId/title"));143 defineCommand(FIND_ELEMENT, post("/session/:sessionId/element"));144 defineCommand(FIND_ELEMENTS, post("/session/:sessionId/elements"));145 defineCommand(GET_ELEMENT_PROPERTY, get("/session/:sessionId/element/:id/property/:name"));146 defineCommand(CLICK_ELEMENT, post("/session/:sessionId/element/:id/click"));147 defineCommand(CLEAR_ELEMENT, post("/session/:sessionId/element/:id/clear"));148 defineCommand(149 GET_ELEMENT_VALUE_OF_CSS_PROPERTY,150 get("/session/:sessionId/element/:id/css/:propertyName"));151 defineCommand(FIND_CHILD_ELEMENT, post("/session/:sessionId/element/:id/element"));152 defineCommand(FIND_CHILD_ELEMENTS, post("/session/:sessionId/element/:id/elements"));153 defineCommand(IS_ELEMENT_ENABLED, get("/session/:sessionId/element/:id/enabled"));154 defineCommand(ELEMENT_EQUALS, get("/session/:sessionId/element/:id/equals/:other"));155 defineCommand(GET_ELEMENT_RECT, get("/session/:sessionId/element/:id/rect"));156 defineCommand(GET_ELEMENT_LOCATION, get("/session/:sessionId/element/:id/location"));157 defineCommand(GET_ELEMENT_TAG_NAME, get("/session/:sessionId/element/:id/name"));158 defineCommand(IS_ELEMENT_SELECTED, get("/session/:sessionId/element/:id/selected"));159 defineCommand(GET_ELEMENT_SIZE, get("/session/:sessionId/element/:id/size"));160 defineCommand(GET_ELEMENT_TEXT, get("/session/:sessionId/element/:id/text"));161 defineCommand(SEND_KEYS_TO_ELEMENT, post("/session/:sessionId/element/:id/value"));162 defineCommand(GET_ALL_COOKIES, get("/session/:sessionId/cookie"));163 defineCommand(GET_COOKIE, get("/session/:sessionId/cookie/:name"));164 defineCommand(ADD_COOKIE, post("/session/:sessionId/cookie"));165 defineCommand(DELETE_ALL_COOKIES, delete("/session/:sessionId/cookie"));166 defineCommand(DELETE_COOKIE, delete("/session/:sessionId/cookie/:name"));167 defineCommand(SET_TIMEOUT, post("/session/:sessionId/timeouts"));168 defineCommand(SET_SCRIPT_TIMEOUT, post("/session/:sessionId/timeouts/async_script"));169 defineCommand(IMPLICITLY_WAIT, post("/session/:sessionId/timeouts/implicit_wait"));170 defineCommand(GET_APP_CACHE_STATUS, get("/session/:sessionId/application_cache/status"));171 defineCommand(IS_BROWSER_ONLINE, get("/session/:sessionId/browser_connection"));172 defineCommand(SET_BROWSER_ONLINE, post("/session/:sessionId/browser_connection"));173 defineCommand(GET_LOCATION, get("/session/:sessionId/location"));174 defineCommand(SET_LOCATION, post("/session/:sessionId/location"));175 defineCommand(GET_SCREEN_ORIENTATION, get("/session/:sessionId/orientation"));176 defineCommand(SET_SCREEN_ORIENTATION, post("/session/:sessionId/orientation"));177 defineCommand(GET_SCREEN_ROTATION, get("/session/:sessionId/rotation"));178 defineCommand(SET_SCREEN_ROTATION, post("/session/:sessionId/rotation"));179 defineCommand(IME_GET_AVAILABLE_ENGINES, get("/session/:sessionId/ime/available_engines"));180 defineCommand(IME_GET_ACTIVE_ENGINE, get("/session/:sessionId/ime/active_engine"));181 defineCommand(IME_IS_ACTIVATED, get("/session/:sessionId/ime/activated"));182 defineCommand(IME_DEACTIVATE, post("/session/:sessionId/ime/deactivate"));183 defineCommand(IME_ACTIVATE_ENGINE, post("/session/:sessionId/ime/activate"));184 // Mobile Spec185 defineCommand(GET_NETWORK_CONNECTION, get("/session/:sessionId/network_connection"));186 defineCommand(SET_NETWORK_CONNECTION, post("/session/:sessionId/network_connection"));187 defineCommand(SWITCH_TO_CONTEXT, post("/session/:sessionId/context"));188 defineCommand(GET_CURRENT_CONTEXT_HANDLE, get("/session/:sessionId/context"));189 defineCommand(GET_CONTEXT_HANDLES, get("/session/:sessionId/contexts"));190 defineCommand(NETWORK_LOG_CAPTURE, post("/session/:sessionId/networklog"));191 defineCommand(GET_MONITOR_STATS, post("/session/:sessionId/monitorstats"));192 }193 @Override194 public HttpRequest encode(Command command) {195 String name = aliases.getOrDefault(command.getName(), command.getName());196 //System.out.println(" [DEBUG] "+String.format("name = %s , Command Name = %s ",name,command.getName()));197 CommandSpec spec = nameToSpec.get(name);198 //System.out.println(" [DEBUG] "+String.format("spec = %s ",spec));199 if (spec == null) {200 throw new UnsupportedCommandException(command.getName());201 }202 Map<String, ?> parameters = amendParameters(command.getName(), command.getParameters());203 String uri = buildUri(name, command.getSessionId(), parameters, spec);204 HttpRequest request = new HttpRequest(spec.method, uri);205 if (HttpMethod.POST == spec.method) {206 String content = json.toJson(parameters);207 byte[] data = content.getBytes(UTF_8);208 request.setHeader(CONTENT_LENGTH, String.valueOf(data.length));209 request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());210 request.setContent(data);211 }212 if (HttpMethod.GET == spec.method) {213 request.setHeader(CACHE_CONTROL, "no-cache");214 }215 return request;216 }217 protected abstract Map<String,?> amendParameters(String name, Map<String, ?> parameters);218 @Override219 public Command decode(final HttpRequest encodedCommand) {220 final String path = Strings.isNullOrEmpty(encodedCommand.getUri())221 ? "/" : encodedCommand.getUri();222 final ImmutableList<String> parts = ImmutableList.copyOf(PATH_SPLITTER.split(path));223 int minPathLength = Integer.MAX_VALUE;224 CommandSpec spec = null;225 String name = null;226 for (Map.Entry<String, CommandSpec> nameValue : nameToSpec.entrySet()) {227 if ((nameValue.getValue().pathSegments.size() < minPathLength)228 && nameValue.getValue().isFor(encodedCommand.getMethod(), parts)) {229 name = nameValue.getKey();230 spec = nameValue.getValue();231 }232 }233 if (name == null) {234 throw new UnsupportedCommandException(235 encodedCommand.getMethod() + " " + encodedCommand.getUri());236 }237 Map<String, Object> parameters = new HashMap<>();238 spec.parsePathParameters(parts, parameters);239 String content = encodedCommand.getContentString();240 if (!content.isEmpty()) {241 @SuppressWarnings("unchecked")242 Map<String, Object> tmp = json.toType(content, MAP_TYPE);243 parameters.putAll(tmp);244 }245 SessionId sessionId = null;246 if (parameters.containsKey(SESSION_ID_PARAM)) {247 String id = (String) parameters.remove(SESSION_ID_PARAM);248 if (id != null) {249 sessionId = new SessionId(id);250 }251 }252 return new Command(sessionId, name, parameters);253 }254 /**255 * Defines a new command mapping.256 *257 * @param name The command name.258 * @param method The HTTP method to use for the command.259 * @param pathPattern The URI path pattern for the command. When encoding a command, each260 * path segment prefixed with a ":" will be replaced with the corresponding parameter261 * from the encoded command.262 */263 public void defineCommand(String name, HttpMethod method, String pathPattern) {264 defineCommand(name, new CommandSpec(method, pathPattern));265 }266 @Override267 public void alias(String commandName, String isAnAliasFor) {268 aliases.put(commandName, isAnAliasFor);269 }270 protected void defineCommand(String name, CommandSpec spec) {271 //System.out.println("[ DEBUG ] Command Spec Initiated for String Name ="+name);272 checkNotNull(name, "null name");273 //System.out.println("[ DEBUG ] Command Spec = "+spec+" String Name ="+name);274 nameToSpec.put(name, spec);275 }276 protected static CommandSpec delete(String path) {277 return new CommandSpec(HttpMethod.DELETE, path);278 }279 protected static CommandSpec get(String path) {280 return new CommandSpec(HttpMethod.GET, path);281 }282 protected static CommandSpec post(String path) {283 return new CommandSpec(HttpMethod.POST, path);284 }285 private String buildUri(286 String commandName,287 SessionId sessionId,288 Map<String, ?> parameters,289 CommandSpec spec) {290 StringBuilder builder = new StringBuilder();291 //System.out.println("[DEBUG] Path segments "+spec.pathSegments);292 for (String part : spec.pathSegments) {293 if (part.isEmpty()) {294 continue;295 }296 builder.append("/");297 if (part.startsWith(":")) {298 builder.append(getParameter(part.substring(1), commandName, sessionId, parameters));299 } else {300 builder.append(part);301 }302 }303 return builder.toString();304 }305 private String getParameter(306 String parameterName,307 String commandName,308 SessionId sessionId,309 Map<String, ?> parameters) {310 if ("sessionId".equals(parameterName)) {311 SessionId id = sessionId;312 checkArgument(id != null, "Session ID may not be null for command %s", commandName);313 return id.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;324 private CommandSpec(HttpMethod method, String path) {325 this.method = checkNotNull(method, "null method");326 this.path = path;327 this.pathSegments = ImmutableList.copyOf(PATH_SPLITTER.split(path));328 }329 @Override330 public boolean equals(Object o) {331 if (o instanceof CommandSpec) {332 CommandSpec that = (CommandSpec) o;333 return this.method.equals(that.method)334 && this.path.equals(that.path);335 }336 return false;337 }338 @Override339 public int hashCode() {340 return Objects.hashCode(method, path);341 }342 /**343 * Returns whether this instance matches the provided HTTP request.344 *345 * @param method The request method.346 * @param parts The parsed request path segments....

Full Screen

Full Screen

Source:JsonHttpCommandHandler.java Github

copy

Full Screen

...14// KIND, either express or implied. See the License for the15// specific language governing permissions and limitations16// under the License.17package org.openqa.selenium.remote.server;18import static org.openqa.selenium.remote.DriverCommand.*;19import org.openqa.selenium.UnsupportedCommandException;20import org.openqa.selenium.remote.Command;21import org.openqa.selenium.remote.CommandCodec;22import org.openqa.selenium.remote.ErrorCodes;23import org.openqa.selenium.remote.Response;24import org.openqa.selenium.remote.ResponseCodec;25import org.openqa.selenium.remote.SessionId;26import org.openqa.selenium.remote.http.HttpRequest;27import org.openqa.selenium.remote.http.HttpResponse;28import org.openqa.selenium.remote.http.JsonHttpCommandCodec;29import org.openqa.selenium.remote.http.JsonHttpResponseCodec;30import org.openqa.selenium.remote.http.W3CHttpCommandCodec;31import org.openqa.selenium.remote.server.handler.AcceptAlert;32import org.openqa.selenium.remote.server.handler.AddCookie;33import org.openqa.selenium.remote.server.handler.CaptureScreenshot;34import org.openqa.selenium.remote.server.handler.ChangeUrl;35import org.openqa.selenium.remote.server.handler.ClearElement;36import org.openqa.selenium.remote.server.handler.ClickElement;37import org.openqa.selenium.remote.server.handler.CloseWindow;38import org.openqa.selenium.remote.server.handler.ConfigureTimeout;39import org.openqa.selenium.remote.server.handler.DeleteCookie;40import org.openqa.selenium.remote.server.handler.DeleteNamedCookie;41import org.openqa.selenium.remote.server.handler.DeleteSession;42import org.openqa.selenium.remote.server.handler.DismissAlert;43import org.openqa.selenium.remote.server.handler.ElementEquality;44import org.openqa.selenium.remote.server.handler.ExecuteAsyncScript;45import org.openqa.selenium.remote.server.handler.ExecuteScript;46import org.openqa.selenium.remote.server.handler.FindActiveElement;47import org.openqa.selenium.remote.server.handler.FindChildElement;48import org.openqa.selenium.remote.server.handler.FindChildElements;49import org.openqa.selenium.remote.server.handler.FindElement;50import org.openqa.selenium.remote.server.handler.FindElements;51import org.openqa.selenium.remote.server.handler.FullscreenWindow;52import org.openqa.selenium.remote.server.handler.GetAlertText;53import org.openqa.selenium.remote.server.handler.GetAllCookies;54import org.openqa.selenium.remote.server.handler.GetAllSessions;55import org.openqa.selenium.remote.server.handler.GetAllWindowHandles;56import org.openqa.selenium.remote.server.handler.GetAvailableLogTypesHandler;57import org.openqa.selenium.remote.server.handler.GetCookie;58import org.openqa.selenium.remote.server.handler.GetCssProperty;59import org.openqa.selenium.remote.server.handler.GetCurrentUrl;60import org.openqa.selenium.remote.server.handler.GetCurrentWindowHandle;61import org.openqa.selenium.remote.server.handler.GetElementAttribute;62import org.openqa.selenium.remote.server.handler.GetElementDisplayed;63import org.openqa.selenium.remote.server.handler.GetElementEnabled;64import org.openqa.selenium.remote.server.handler.GetElementLocation;65import org.openqa.selenium.remote.server.handler.GetElementLocationInView;66import org.openqa.selenium.remote.server.handler.GetElementRect;67import org.openqa.selenium.remote.server.handler.GetElementSelected;68import org.openqa.selenium.remote.server.handler.GetElementSize;69import org.openqa.selenium.remote.server.handler.GetElementText;70import org.openqa.selenium.remote.server.handler.GetLogHandler;71import org.openqa.selenium.remote.server.handler.GetPageSource;72import org.openqa.selenium.remote.server.handler.GetScreenOrientation;73import org.openqa.selenium.remote.server.handler.GetSessionCapabilities;74import org.openqa.selenium.remote.server.handler.GetSessionLogsHandler;75import org.openqa.selenium.remote.server.handler.GetTagName;76import org.openqa.selenium.remote.server.handler.GetTitle;77import org.openqa.selenium.remote.server.handler.GetWindowPosition;78import org.openqa.selenium.remote.server.handler.GetWindowSize;79import org.openqa.selenium.remote.server.handler.GoBack;80import org.openqa.selenium.remote.server.handler.GoForward;81import org.openqa.selenium.remote.server.handler.ImeActivateEngine;82import org.openqa.selenium.remote.server.handler.ImeDeactivate;83import org.openqa.selenium.remote.server.handler.ImeGetActiveEngine;84import org.openqa.selenium.remote.server.handler.ImeGetAvailableEngines;85import org.openqa.selenium.remote.server.handler.ImeIsActivated;86import org.openqa.selenium.remote.server.handler.ImplicitlyWait;87import org.openqa.selenium.remote.server.handler.MaximizeWindow;88import org.openqa.selenium.remote.server.handler.RefreshPage;89import org.openqa.selenium.remote.server.handler.Rotate;90import org.openqa.selenium.remote.server.handler.SendKeys;91import org.openqa.selenium.remote.server.handler.SetAlertText;92import org.openqa.selenium.remote.server.handler.SetScriptTimeout;93import org.openqa.selenium.remote.server.handler.SetWindowPosition;94import org.openqa.selenium.remote.server.handler.SetWindowSize;95import org.openqa.selenium.remote.server.handler.Status;96import org.openqa.selenium.remote.server.handler.SubmitElement;97import org.openqa.selenium.remote.server.handler.SwitchToFrame;98import org.openqa.selenium.remote.server.handler.SwitchToParentFrame;99import org.openqa.selenium.remote.server.handler.SwitchToWindow;100import org.openqa.selenium.remote.server.handler.UploadFile;101import org.openqa.selenium.remote.server.handler.W3CActions;102import org.openqa.selenium.remote.server.handler.html5.ClearLocalStorage;103import org.openqa.selenium.remote.server.handler.html5.ClearSessionStorage;104import org.openqa.selenium.remote.server.handler.html5.GetAppCacheStatus;105import org.openqa.selenium.remote.server.handler.html5.GetLocalStorageItem;106import org.openqa.selenium.remote.server.handler.html5.GetLocalStorageKeys;107import org.openqa.selenium.remote.server.handler.html5.GetLocalStorageSize;108import org.openqa.selenium.remote.server.handler.html5.GetLocationContext;109import org.openqa.selenium.remote.server.handler.html5.GetSessionStorageItem;110import org.openqa.selenium.remote.server.handler.html5.GetSessionStorageKeys;111import org.openqa.selenium.remote.server.handler.html5.GetSessionStorageSize;112import org.openqa.selenium.remote.server.handler.html5.RemoveLocalStorageItem;113import org.openqa.selenium.remote.server.handler.html5.RemoveSessionStorageItem;114import org.openqa.selenium.remote.server.handler.html5.SetLocalStorageItem;115import org.openqa.selenium.remote.server.handler.html5.SetLocationContext;116import org.openqa.selenium.remote.server.handler.html5.SetSessionStorageItem;117import org.openqa.selenium.remote.server.handler.interactions.ClickInSession;118import org.openqa.selenium.remote.server.handler.interactions.DoubleClickInSession;119import org.openqa.selenium.remote.server.handler.interactions.MouseDown;120import org.openqa.selenium.remote.server.handler.interactions.MouseMoveToLocation;121import org.openqa.selenium.remote.server.handler.interactions.MouseUp;122import org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement;123import org.openqa.selenium.remote.server.handler.interactions.touch.DoubleTapOnElement;124import org.openqa.selenium.remote.server.handler.interactions.touch.Down;125import org.openqa.selenium.remote.server.handler.interactions.touch.Flick;126import org.openqa.selenium.remote.server.handler.interactions.touch.LongPressOnElement;127import org.openqa.selenium.remote.server.handler.interactions.touch.Move;128import org.openqa.selenium.remote.server.handler.interactions.touch.Scroll;129import org.openqa.selenium.remote.server.handler.interactions.touch.SingleTapOnElement;130import org.openqa.selenium.remote.server.handler.interactions.touch.Up;131import org.openqa.selenium.remote.server.handler.mobile.GetNetworkConnection;132import org.openqa.selenium.remote.server.handler.mobile.SetNetworkConnection;133import org.openqa.selenium.remote.server.log.LoggingManager;134import org.openqa.selenium.remote.server.log.PerSessionLogHandler;135import org.openqa.selenium.remote.server.rest.RestishHandler;136import org.openqa.selenium.remote.server.rest.ResultConfig;137import java.io.IOException;138import java.util.LinkedHashMap;139import java.util.LinkedHashSet;140import java.util.Map;141import java.util.Set;142import java.util.logging.Logger;143public class JsonHttpCommandHandler {144 private final DriverSessions sessions;145 private final Logger log;146 private final Set<CommandCodec<HttpRequest>> commandCodecs;147 private final ResponseCodec<HttpResponse> responseCodec;148 private final Map<String, ResultConfig> configs = new LinkedHashMap<>();149 private final ErrorCodes errorCodes = new ErrorCodes();150 public JsonHttpCommandHandler(DriverSessions sessions, Logger log) {151 this.sessions = sessions;152 this.log = log;153 this.commandCodecs = new LinkedHashSet<>();154 this.commandCodecs.add(new JsonHttpCommandCodec());155 this.commandCodecs.add(new W3CHttpCommandCodec());156 this.responseCodec = new JsonHttpResponseCodec();157 setUpMappings();158 }159 public void addNewMapping(160 String commandName,161 Class<? extends RestishHandler<?>> implementationClass) {162 ResultConfig config = new ResultConfig(commandName, implementationClass, sessions, log);163 configs.put(commandName, config);164 }165 public void handleRequest(HttpRequest request, HttpResponse resp) throws IOException {166 LoggingManager.perSessionLogHandler().clearThreadTempLogs();167 log.fine(String.format("Handling: %s %s", request.getMethod(), request.getUri()));168 Command command = null;169 Response response;170 try {171 command = decode(request);172 ResultConfig config = configs.get(command.getName());173 if (config == null) {174 throw new UnsupportedCommandException();175 }176 response = config.handle(command);177 log.fine(String.format("Finished: %s %s", request.getMethod(), request.getUri()));178 } catch (Exception e) {179 log.fine(String.format("Error on: %s %s", request.getMethod(), request.getUri()));180 response = new Response();181 response.setStatus(errorCodes.toStatusCode(e));182 response.setState(errorCodes.toState(response.getStatus()));183 response.setValue(e);184 if (command != null && command.getSessionId() != null) {185 response.setSessionId(command.getSessionId().toString());186 }187 }188 PerSessionLogHandler handler = LoggingManager.perSessionLogHandler();189 if (response.getSessionId() != null) {190 handler.attachToCurrentThread(new SessionId(response.getSessionId()));191 }192 try {193 responseCodec.encode(() -> resp, response);194 } finally {195 handler.detachFromCurrentThread();196 }197 }198 private Command decode(HttpRequest request) {199 UnsupportedCommandException lastException = null;200 for (CommandCodec<HttpRequest> codec : commandCodecs) {201 try {202 return codec.decode(request);203 } catch (UnsupportedCommandException e) {204 lastException = e;205 }206 }207 if (lastException != null) {208 throw lastException;209 }210 throw new UnsupportedOperationException("Cannot find command for: " + request.getUri());211 }212 private void setUpMappings() {213 addNewMapping(STATUS, Status.class);214 addNewMapping(GET_ALL_SESSIONS, GetAllSessions.class);215 addNewMapping(GET_CAPABILITIES, GetSessionCapabilities.class);216 addNewMapping(QUIT, DeleteSession.class);217 addNewMapping(GET_CURRENT_WINDOW_HANDLE, GetCurrentWindowHandle.class);...

Full Screen

Full Screen

Source:NLPerfectoWebDriver.java Github

copy

Full Screen

...35import org.openqa.selenium.WebDriverException;36import org.openqa.selenium.WebElement;37import org.openqa.selenium.interactions.Keyboard;38import org.openqa.selenium.interactions.Mouse;39import org.openqa.selenium.remote.CommandExecutor;40import org.openqa.selenium.remote.ErrorHandler;41import org.openqa.selenium.remote.FileDetector;42import org.openqa.selenium.remote.RemoteWebDriver;43import org.openqa.selenium.remote.SessionId;44import com.neotys.selenium.proxies.helpers.WrapperUtils;45public class NLPerfectoWebDriver extends NLRemoteWebDriver{46 47 private final RemoteWebDriver remoteWebDriver;48 private final NLWebDriver webDriver;49 private final WrapperUtils wrapperUtils;50 51 public NLPerfectoWebDriver(final RemoteWebDriver originalWebDriver, final NLWebDriver webDriver,52 final WrapperUtils wrapperUtils) {53 this.remoteWebDriver = originalWebDriver;54 this.webDriver = webDriver;55 this.wrapperUtils = wrapperUtils;56 }57 58 /**59 * @return60 * @see java.lang.Object#hashCode()61 */62 @Override63 public int hashCode() {64 return webDriver.hashCode();65 }66 /**67 * @param obj68 * @return69 * @see java.lang.Object#equals(java.lang.Object)70 */71 @Override72 public boolean equals(Object obj) {73 return webDriver.equals(obj);74 }75 /**76 * @param detector77 * @see org.openqa.selenium.remote.RemoteWebDriver#setFileDetector(org.openqa.selenium.remote.FileDetector)78 */79 @Override80 public void setFileDetector(FileDetector detector) {81 remoteWebDriver.setFileDetector(detector);82 }83 /**84 * @return85 * @see org.openqa.selenium.remote.RemoteWebDriver#getSessionId()86 */87 @Override88 public SessionId getSessionId() {89 return wrapperUtils.wrapIfNecessary(webDriver, remoteWebDriver.getSessionId());90 }91 /**92 * @return93 * @see org.openqa.selenium.remote.RemoteWebDriver#getErrorHandler()94 */95 @Override96 public ErrorHandler getErrorHandler() {97 return wrapperUtils.wrapIfNecessary(webDriver, remoteWebDriver.getErrorHandler());98 }99 /**100 * @param handler101 * @see org.openqa.selenium.remote.RemoteWebDriver#setErrorHandler(org.openqa.selenium.remote.ErrorHandler)102 */103 @Override104 public void setErrorHandler(ErrorHandler handler) {105 remoteWebDriver.setErrorHandler(handler);106 }107 /**108 * @return109 * @see org.openqa.selenium.remote.RemoteWebDriver#getCommandExecutor()110 */111 @Override112 public CommandExecutor getCommandExecutor() {113 return wrapperUtils.wrapIfNecessary(webDriver, remoteWebDriver.getCommandExecutor());114 }115 /**116 * @return117 * @see org.openqa.selenium.remote.RemoteWebDriver#getCapabilities()118 */119 @Override120 public Capabilities getCapabilities() {121 return wrapperUtils.wrapIfNecessary(webDriver, remoteWebDriver.getCapabilities());122 }123 /**124 * @param url125 * @see org.openqa.selenium.remote.RemoteWebDriver#get(java.lang.String)126 */127 @Override...

Full Screen

Full Screen

Source:CommandHandler.java Github

copy

Full Screen

1package ru.stqa.selenium.zkgrid.node;2import org.openqa.selenium.UnsupportedCommandException;3import org.openqa.selenium.remote.Command;4import org.openqa.selenium.remote.ErrorCodes;5import org.openqa.selenium.remote.Response;6import shaded.org.openqa.selenium.remote.server.DriverSessions;7import shaded.org.openqa.selenium.remote.server.rest.RestishHandler;8import shaded.org.openqa.selenium.remote.server.rest.ResultConfig;9import org.slf4j.Logger;10import org.slf4j.LoggerFactory;11import java.util.HashMap;12import java.util.Map;13import static org.openqa.selenium.remote.DriverCommand.*;14public class CommandHandler {15 private static Logger log = LoggerFactory.getLogger(Node.class);16 private final DriverSessions sessions;17 private final Map<String, ResultConfig> configs = new HashMap<String, ResultConfig>();18 private final ErrorCodes errorCodes = new ErrorCodes();19 public CommandHandler(DriverSessions sessions) {20 this.sessions = sessions;21 setUpMappings();22 }23 public Response handleCommand(Command command) {24 log.info("Handling command " + command);25 Response response;26 try {27 ResultConfig config = configs.get(command.getName());28 if (config == null) {29 throw new UnsupportedCommandException();30 }31 response = config.handle(command);32 log.info("Finished " + command);33 } catch (Exception e) {34 log.info(String.format("Error on " + command));35 e.printStackTrace();36 response = new Response();37 response.setStatus(errorCodes.toStatusCode(e));38 response.setState(errorCodes.toState(response.getStatus()));39 response.setValue(e);40 if (command != null && command.getSessionId() != null) {41 response.setSessionId(command.getSessionId().toString());42 }43 }...

Full Screen

Full Screen

Source:JsonHttpCommandCodec.java Github

copy

Full Screen

...14// 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

Source:RemoteSession.java Github

copy

Full Screen

...23import org.openqa.selenium.ImmutableCapabilities;24import org.openqa.selenium.WebDriver;25import org.openqa.selenium.io.TemporaryFilesystem;26import org.openqa.selenium.remote.Augmenter;27import org.openqa.selenium.remote.Command;28import org.openqa.selenium.remote.CommandCodec;29import org.openqa.selenium.remote.CommandExecutor;30import org.openqa.selenium.remote.Dialect;31import org.openqa.selenium.remote.DriverCommand;32import org.openqa.selenium.remote.ProtocolHandshake;33import org.openqa.selenium.remote.RemoteWebDriver;34import org.openqa.selenium.remote.Response;35import org.openqa.selenium.remote.ResponseCodec;36import org.openqa.selenium.remote.SessionId;37import org.openqa.selenium.remote.http.HttpClient;38import org.openqa.selenium.remote.http.HttpRequest;39import org.openqa.selenium.remote.http.HttpResponse;40import org.openqa.selenium.remote.http.JsonHttpCommandCodec;41import org.openqa.selenium.remote.http.JsonHttpResponseCodec;42import org.openqa.selenium.remote.http.W3CHttpCommandCodec;43import org.openqa.selenium.remote.http.W3CHttpResponseCodec;44import java.io.File;45import java.io.IOException;46import java.net.URL;47import java.util.Map;48import java.util.Optional;49import java.util.Set;50import java.util.logging.Level;51import java.util.logging.Logger;52/**53 * Abstract class designed to do things like protocol conversion.54 */55public abstract class RemoteSession implements ActiveSession {56 protected static Logger log = Logger.getLogger(ActiveSession.class.getName());57 private final SessionId id;58 private final Dialect downstream;59 private final Dialect upstream;60 private final SessionCodec codec;61 private final Map<String, Object> capabilities;62 private final TemporaryFilesystem filesystem;63 private final WebDriver driver;64 protected RemoteSession(65 Dialect downstream,66 Dialect upstream,67 SessionCodec codec,68 SessionId id,69 Map<String, Object> capabilities) {70 this.downstream = downstream;71 this.upstream = upstream;72 this.codec = codec;73 this.id = id;74 this.capabilities = capabilities;75 File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());76 Preconditions.checkState(tempRoot.mkdirs());77 this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);78 CommandExecutor executor = new ActiveSessionCommandExecutor(this);79 this.driver = new Augmenter().augment(new RemoteWebDriver(80 executor,81 new ImmutableCapabilities(getCapabilities())));82 }83 @Override84 public SessionId getId() {85 return id;86 }87 @Override88 public Dialect getUpstreamDialect() {89 return upstream;90 }91 @Override92 public Dialect getDownstreamDialect() {93 return downstream;94 }95 @Override96 public Map<String, Object> getCapabilities() {97 return capabilities;98 }99 @Override100 public TemporaryFilesystem getFileSystem() {101 return filesystem;102 }103 @Override104 public WebDriver getWrappedDriver() {105 return driver;106 }107 @Override108 public void execute(HttpRequest req, HttpResponse resp) throws IOException {109 codec.handle(req, resp);110 }111 public abstract static class Factory<X> implements SessionFactory {112 protected Optional<ActiveSession> performHandshake(113 X additionalData,114 URL url,115 Set<Dialect> downstreamDialects,116 Capabilities capabilities) {117 try {118 HttpClient client = HttpClient.Factory.createDefault().createClient(url);119 Command command = new Command(120 null,121 DriverCommand.NEW_SESSION,122 ImmutableMap.of("desiredCapabilities", capabilities));123 ProtocolHandshake.Result result = new ProtocolHandshake().createSession(client, command);124 SessionCodec codec;125 Dialect upstream = result.getDialect();126 Dialect downstream;127 if (downstreamDialects.contains(result.getDialect())) {128 codec = new Passthrough(url);129 downstream = upstream;130 } else {131 downstream = downstreamDialects.isEmpty() ? OSS : downstreamDialects.iterator().next();132 codec = new ProtocolConverter(133 url,134 getCommandCodec(downstream),135 getResponseCodec(downstream),136 getCommandCodec(upstream),137 getResponseCodec(upstream));138 }139 Response response = result.createResponse();140 //noinspection unchecked141 Optional<ActiveSession> activeSession = Optional.of(newActiveSession(142 additionalData,143 downstream,144 upstream,145 codec,146 new SessionId(response.getSessionId()),147 (Map<String, Object>) response.getValue()));148 activeSession.ifPresent(session -> log.info("Started new session " + session));149 return activeSession;150 } catch (IOException | IllegalStateException | NullPointerException e) {151 log.log(Level.WARNING, e.getMessage(), e);152 return Optional.empty();153 }154 }155 protected abstract ActiveSession newActiveSession(156 X additionalData,157 Dialect downstream,158 Dialect upstream,159 SessionCodec codec,160 SessionId id,161 Map<String, Object> capabilities);162 private CommandCodec<HttpRequest> getCommandCodec(Dialect dialect) {163 switch (dialect) {164 case OSS:165 return new JsonHttpCommandCodec();166 case W3C:167 return new W3CHttpCommandCodec();168 default:169 throw new IllegalStateException("Unknown dialect: " + dialect);170 }171 }172 private ResponseCodec<HttpResponse> getResponseCodec(Dialect dialect) {173 switch (dialect) {174 case OSS:175 return new JsonHttpResponseCodec();176 case W3C:177 return new W3CHttpResponseCodec();178 default:179 throw new IllegalStateException("Unknown dialect: " + dialect);180 }181 }...

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.http.HttpClient;2import org.openqa.selenium.remote.http.HttpMethod;3import org.openqa.selenium.remote.http.HttpRequest;4import org.openqa.selenium.remote.http.HttpResponse;5import org.openqa.selenium.remote.http.JsonHttpCommandCodec;6import org.openqa.selenium.remote.http.JsonHttpResponseCodec;7import org.openqa.selenium.remote.internal.ApacheHttpClient;8import java.io.IOException;9import java.net.MalformedURLException;10import java.net.URL;11import java.util.HashMap;12import java.util.Map;13public class Example {14 public static void main(String[] args) throws MalformedURLException {15 HttpClient client = new ApacheHttpClient();16 JsonHttpCommandCodec codec = new JsonHttpCommandCodec();17 JsonHttpResponseCodec responseCodec = new JsonHttpResponseCodec();18 HttpRequest request = new HttpRequest(HttpMethod.GET, "/session/4c92e4a1-4e4f-4a1b-bf7f-2b2f6b2e8d70/element");19 Command command = new Command(null, DriverCommand.FIND_ELEMENT);20 Map<String, Object> params = new HashMap<>();

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.Command;2import org.openqa.selenium.remote.DesiredCapabilities;3import java.net.URL;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.support.ui.WebDriverWait;8import org.openqa.selenium.support.ui.ExpectedConditions;9import java.util.concurrent.TimeUnit;10import org.openqa.selenium.Keys;11import org.openqa.selenium.JavascriptExecutor;12import org.openqa.selenium.interactions.Actions;13import org.openqa.selenium.remote.RemoteWebDriver;14import org.openqa.selenium.remote.SessionId;15import org.openqa.selenium.remote.CommandExecutor;16public class RemoteWebDriverExample {17 public static void main(String[] args) throws Exception {18 DesiredCapabilities capabilities = new DesiredCapabilities();19 System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");20 capabilities.setCapability("browserName", "chrome");21 capabilities.setCapability("version", "62.0");22 capabilities.setCapability("platform", "WINDOWS");23 capabilities.setCapability("build", "RemoteWebDriver");24 capabilities.setCapability("project", "RemoteWebDriver");

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.Command;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.remote.RemoteWebDriver;4import java.net.URL;5public class RemoteWebDriverTest {6 public static void main(String[] args) throws Exception {7 DesiredCapabilities capabilities = DesiredCapabilities.chrome();8 System.out.println("Title of the page is: " + driver.getTitle());9 System.out.println("Current url is: " + driver.getCurrentUrl());10 System.out.println("Page source is: " + driver.getPageSource());11 driver.close();12 }13}

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.Command;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.remote.Platform;4import org.openqa.selenium.remote.RemoteWebDriver;5{6 public static void main(String[] args) 7 {8 WebElement element = driver.findElement(By.name("q"));9 element.sendKeys("Cheese!");10 element.submit();11 System.out.println("Page title is: " + driver.getTitle());12 driver.quit();13 }14}

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.remote.Command;2import org.openqa.selenium.remote.Response;3import org.openqa.selenium.remote.DriverCommand;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.remote.RemoteExecuteMethod;8public class RemoteExecuteMethodExample {9 public static void main(String[] args) {10 ChromeOptions options = new ChromeOptions();11 options.setExperimentalOption("debuggerAddress", "localhost:9222");12 WebDriver driver = new ChromeDriver(options);13 RemoteExecuteMethod executeMethod = new RemoteExecuteMethod((ChromeDriver) driver);14 Command command = new Command(((ChromeDriver) driver).getSessionId(), DriverCommand.GET_CURRENT_URL);15 Response response = executeMethod.execute(command);16 System.out.println(response.getValue());17 }18}

Full Screen

Full Screen

Command

Using AI Code Generation

copy

Full Screen

1at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)2at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)3at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)4at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)5at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:121)6at com.test.automation.selenium.testcases.TestSelenium2.testSelenium2(TestSelenium2.java:29)7at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)8at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)9at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)10at java.lang.reflect.Method.invoke(Method.java:597)11at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)12at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)13at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)14at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)15at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)16at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)17at org.testng.TestRunner.privateRun(TestRunner.java:767)18at org.testng.TestRunner.run(TestRunner.java:617)19at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)20at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

Full Screen

Full Screen
copy
1 clientConfig = new DefaultClientConfig();2 client = Client.create(clientConfig);34 resource = client.resource("http://localhost:8080");5 // lets get the XML as a String6 String text = resource("foo").accept("application/xml").get(String.class); 7
Full Screen
copy
1private void updateCustomer(Customer customer) { 2 try { 3 URL url = new URL("http://www.example.com/customers"); 4 HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 5 connection.setDoOutput(true); 6 connection.setInstanceFollowRedirects(false); 7 connection.setRequestMethod("PUT"); 8 connection.setRequestProperty("Content-Type", "application/xml"); 910 OutputStream os = connection.getOutputStream(); 11 jaxbContext.createMarshaller().marshal(customer, os); 12 os.flush(); 1314 connection.getResponseCode(); 15 connection.disconnect(); 16 } catch(Exception e) { 17 throw new RuntimeException(e); 18 } 19} 20
Full Screen
copy
1// Make a GET request to "/lotto"2String json = get("/lotto").asString()3// Parse the JSON response4List<String> winnderIds = with(json).get("lotto.winners.winnerId");56// Make a POST request to "/shopping"7String xml = post("/shopping").andReturn().body().asString()8// Parse the XML9Node category = with(xml).get("shopping.category[0]");10
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.

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