How to use map method of org.openqa.selenium.internal.Either class

Best Selenium code snippet using org.openqa.selenium.internal.Either.map

Source:WebDriverCommandProcessor.java Github

copy

Full Screen

1/*2Copyright 2007-2009 WebDriver committers3Copyright 2007-2009 Google Inc.45Licensed under the Apache License, Version 2.0 (the "License");6you may not use this file except in compliance with the License.7You may obtain a copy of the License at89 http://www.apache.org/licenses/LICENSE-2.01011Unless required by applicable law or agreed to in writing, software12distributed under the License is distributed on an "AS IS" BASIS,13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14See the License for the specific language governing permissions and15limitations under the License.16*/1718package org.openqa.selenium;1920import com.google.common.annotations.VisibleForTesting;21import com.google.common.base.Supplier;22import com.google.common.collect.Maps;2324import com.thoughtworks.selenium.CommandProcessor;25import com.thoughtworks.selenium.SeleniumException;2627import org.openqa.selenium.internal.WrapsDriver;28import org.openqa.selenium.internal.seleniumemulation.AddLocationStrategy;29import org.openqa.selenium.internal.seleniumemulation.AddSelection;30import org.openqa.selenium.internal.seleniumemulation.AlertOverride;31import org.openqa.selenium.internal.seleniumemulation.AltKeyDown;32import org.openqa.selenium.internal.seleniumemulation.AltKeyUp;33import org.openqa.selenium.internal.seleniumemulation.AssignId;34import org.openqa.selenium.internal.seleniumemulation.AttachFile;35import org.openqa.selenium.internal.seleniumemulation.CaptureScreenshotToString;36import org.openqa.selenium.internal.seleniumemulation.Check;37import org.openqa.selenium.internal.seleniumemulation.Click;38import org.openqa.selenium.internal.seleniumemulation.Close;39import org.openqa.selenium.internal.seleniumemulation.CompoundMutator;40import org.openqa.selenium.internal.seleniumemulation.ControlKeyDown;41import org.openqa.selenium.internal.seleniumemulation.ControlKeyUp;42import org.openqa.selenium.internal.seleniumemulation.CreateCookie;43import org.openqa.selenium.internal.seleniumemulation.DeleteAllVisibleCookies;44import org.openqa.selenium.internal.seleniumemulation.DeleteCookie;45import org.openqa.selenium.internal.seleniumemulation.DoubleClick;46import org.openqa.selenium.internal.seleniumemulation.DragAndDrop;47import org.openqa.selenium.internal.seleniumemulation.ElementFinder;48import org.openqa.selenium.internal.seleniumemulation.FindFirstSelectedOptionProperty;49import org.openqa.selenium.internal.seleniumemulation.FindSelectedOptionProperties;50import org.openqa.selenium.internal.seleniumemulation.FireEvent;51import org.openqa.selenium.internal.seleniumemulation.FireNamedEvent;52import org.openqa.selenium.internal.seleniumemulation.GetAlert;53import org.openqa.selenium.internal.seleniumemulation.GetAllButtons;54import org.openqa.selenium.internal.seleniumemulation.GetAllFields;55import org.openqa.selenium.internal.seleniumemulation.GetAllLinks;56import org.openqa.selenium.internal.seleniumemulation.GetAllWindowTitles;57import org.openqa.selenium.internal.seleniumemulation.GetAttribute;58import org.openqa.selenium.internal.seleniumemulation.GetAttributeFromAllWindows;59import org.openqa.selenium.internal.seleniumemulation.GetBodyText;60import org.openqa.selenium.internal.seleniumemulation.GetConfirmation;61import org.openqa.selenium.internal.seleniumemulation.GetCookie;62import org.openqa.selenium.internal.seleniumemulation.GetCookieByName;63import org.openqa.selenium.internal.seleniumemulation.GetElementHeight;64import org.openqa.selenium.internal.seleniumemulation.GetElementIndex;65import org.openqa.selenium.internal.seleniumemulation.GetElementPositionLeft;66import org.openqa.selenium.internal.seleniumemulation.GetElementPositionTop;67import org.openqa.selenium.internal.seleniumemulation.GetElementWidth;68import org.openqa.selenium.internal.seleniumemulation.GetEval;69import org.openqa.selenium.internal.seleniumemulation.GetExpression;70import org.openqa.selenium.internal.seleniumemulation.GetHtmlSource;71import org.openqa.selenium.internal.seleniumemulation.GetLocation;72import org.openqa.selenium.internal.seleniumemulation.GetSelectOptions;73import org.openqa.selenium.internal.seleniumemulation.GetTable;74import org.openqa.selenium.internal.seleniumemulation.GetText;75import org.openqa.selenium.internal.seleniumemulation.GetTitle;76import org.openqa.selenium.internal.seleniumemulation.GetValue;77import org.openqa.selenium.internal.seleniumemulation.GetXpathCount;78import org.openqa.selenium.internal.seleniumemulation.GoBack;79import org.openqa.selenium.internal.seleniumemulation.Highlight;80import org.openqa.selenium.internal.seleniumemulation.IsAlertPresent;81import org.openqa.selenium.internal.seleniumemulation.IsChecked;82import org.openqa.selenium.internal.seleniumemulation.IsConfirmationPresent;83import org.openqa.selenium.internal.seleniumemulation.IsCookiePresent;84import org.openqa.selenium.internal.seleniumemulation.IsEditable;85import org.openqa.selenium.internal.seleniumemulation.IsElementPresent;86import org.openqa.selenium.internal.seleniumemulation.IsOrdered;87import org.openqa.selenium.internal.seleniumemulation.IsSomethingSelected;88import org.openqa.selenium.internal.seleniumemulation.IsTextPresent;89import org.openqa.selenium.internal.seleniumemulation.IsVisible;90import org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary;91import org.openqa.selenium.internal.seleniumemulation.KeyEvent;92import org.openqa.selenium.internal.seleniumemulation.KeyState;93import org.openqa.selenium.internal.seleniumemulation.MetaKeyDown;94import org.openqa.selenium.internal.seleniumemulation.MetaKeyUp;95import org.openqa.selenium.internal.seleniumemulation.MouseEvent;96import org.openqa.selenium.internal.seleniumemulation.MouseEventAt;97import org.openqa.selenium.internal.seleniumemulation.NoOp;98import org.openqa.selenium.internal.seleniumemulation.Open;99import org.openqa.selenium.internal.seleniumemulation.OpenWindow;100import org.openqa.selenium.internal.seleniumemulation.Refresh;101import org.openqa.selenium.internal.seleniumemulation.RemoveAllSelections;102import org.openqa.selenium.internal.seleniumemulation.RemoveSelection;103import org.openqa.selenium.internal.seleniumemulation.RunScript;104import org.openqa.selenium.internal.seleniumemulation.ScriptMutator;105import org.openqa.selenium.internal.seleniumemulation.SelectFrame;106import org.openqa.selenium.internal.seleniumemulation.SelectOption;107import org.openqa.selenium.internal.seleniumemulation.SelectWindow;108import org.openqa.selenium.internal.seleniumemulation.SeleneseCommand;109import org.openqa.selenium.internal.seleniumemulation.SetNextConfirmationState;110import org.openqa.selenium.internal.seleniumemulation.SetTimeout;111import org.openqa.selenium.internal.seleniumemulation.ShiftKeyDown;112import org.openqa.selenium.internal.seleniumemulation.ShiftKeyUp;113import org.openqa.selenium.internal.seleniumemulation.Submit;114import org.openqa.selenium.internal.seleniumemulation.Timer;115import org.openqa.selenium.internal.seleniumemulation.Type;116import org.openqa.selenium.internal.seleniumemulation.TypeKeys;117import org.openqa.selenium.internal.seleniumemulation.Uncheck;118import org.openqa.selenium.internal.seleniumemulation.WaitForCondition;119import org.openqa.selenium.internal.seleniumemulation.WaitForPageToLoad;120import org.openqa.selenium.internal.seleniumemulation.WaitForPopup;121import org.openqa.selenium.internal.seleniumemulation.WindowFocus;122import org.openqa.selenium.internal.seleniumemulation.WindowMaximize;123import org.openqa.selenium.internal.seleniumemulation.Windows;124import org.openqa.selenium.remote.DesiredCapabilities;125126import java.util.Map;127128129/**130 * A CommandProcessor which delegates commands down to an underlying webdriver131 * instance.132 */133public class WebDriverCommandProcessor implements CommandProcessor, WrapsDriver {134 private final Map<String, SeleneseCommand<?>> seleneseMethods = Maps.newHashMap();135 private final String baseUrl;136 private final Timer timer;137 private final CompoundMutator scriptMutator;138 private Supplier<WebDriver> maker;139 private WebDriver driver;140141 /**142 * Create an instance that will later be configured by calling143 * {@link #start(Object)} with a {@link Capabilities}144 * instance.145 *146 * @param baseUrl The URL from which relative URLs should be based on147 */148 public WebDriverCommandProcessor(String baseUrl) {149 // Firefox seems like a reasonable default150 this(baseUrl, new SuppliesWebDriver(DesiredCapabilities.firefox()));151 }152153 /**154 * Create an instance that will later be started by calling155 * {@link #start()}156 *157 * @param baseUrl The URL from which relative URLs should be based on158 * @param likeThis Typically a {@link org.openqa.selenium.remote.DesiredCapabilities} instance159 */160 public WebDriverCommandProcessor(String baseUrl, Capabilities likeThis) {161 this(baseUrl, new SuppliesWebDriver(likeThis));162 }163164 public WebDriverCommandProcessor(String baseUrl, WebDriver driver) {165 this(baseUrl, new ExplodingSupplier());166 this.driver = driver;167168 assertDriverSupportsJavascript(driver);169170 setUpMethodMap();171 }172173 public WebDriverCommandProcessor(String baseUrl, Supplier<WebDriver> maker) {174 this.maker = maker;175176 if (baseUrl.endsWith("/")) {177 this.baseUrl = baseUrl.substring(0, baseUrl.length() - 1);178 } else {179 this.baseUrl = baseUrl;180 }181182 this.timer = new Timer(30000);183 this.scriptMutator = new CompoundMutator(baseUrl);184 }185186 public WebDriver getWrappedDriver() {187 return driver;188 }189190 public String getRemoteControlServerLocation() {191 throw new UnsupportedOperationException();192 }193194 public String doCommand(String commandName, String[] args) {195 Object val = execute(commandName, args);196 if (val == null) {197 return null;198 }199200 return val.toString();201 }202203 public void setExtensionJs(String s) {204 throw new UnsupportedOperationException();205 }206207 public void start() {208 start((Object) null);209 }210211 public void start(String s) {212 throw new UnsupportedOperationException("Unsure how to process: " + s);213 }214215 public void start(Object o) {216 if (driver != null) {217 throw new SeleniumException("You may not start more than one session at a time");218 }219220 driver = maker.get();221222 assertDriverSupportsJavascript(driver);223224 setUpMethodMap();225 }226227 public void stop() {228 timer.stop();229 if (driver != null) {230 driver.quit();231 }232 driver = null;233 }234235 public String getString(String commandName, String[] args) {236 return (String) execute(commandName, args);237 }238239 public String[] getStringArray(String commandName, String[] args) {240 return (String[]) execute(commandName, args);241 }242243 public Number getNumber(String commandName, String[] args) {244 return (Number) execute(commandName, args);245 }246247 public Number[] getNumberArray(String s, String[] strings) {248 throw new UnsupportedOperationException();249 }250251 public boolean getBoolean(String commandName, String[] args) {252 return (Boolean) execute(commandName, args);253 }254255 public boolean[] getBooleanArray(String s, String[] strings) {256 throw new UnsupportedOperationException();257 }258259 private Object execute(String commandName, final String[] args) {260 final SeleneseCommand<?> command = seleneseMethods.get(commandName);261 if (command == null) {262 throw new UnsupportedOperationException(commandName);263 }264265 return timer.run(command, driver, args);266 }267268 public void addMutator(ScriptMutator mutator) {269 scriptMutator.addMutator(mutator);270 }271272 public boolean isMethodAvailable(String methodName) {273 return seleneseMethods.containsKey(methodName);274 }275276 public void addMethod(String methodName, SeleneseCommand command) {277 seleneseMethods.put(methodName, command);278 }279280 public SeleneseCommand getMethod(String methodName) {281 return seleneseMethods.get(methodName);282 }283284 @VisibleForTesting285 protected void assertDriverSupportsJavascript(WebDriver driver) {286 if (!(driver instanceof JavascriptExecutor)) {287 throw new IllegalStateException("Driver instance must support JS.");288 }289290 if (!(driver instanceof HasCapabilities)) {291 // Might be proxy. Bail.292 return;293 }294295 if (!((HasCapabilities) driver).getCapabilities().isJavascriptEnabled()) {296 throw new IllegalStateException("JS support must be enabled.");297 }298 }299300 private void setUpMethodMap() {301 JavascriptLibrary javascriptLibrary = new JavascriptLibrary();302 ElementFinder elementFinder = new ElementFinder(javascriptLibrary);303 KeyState keyState = new KeyState();304305 AlertOverride alertOverride = new AlertOverride();306 Windows windows = new Windows(driver);307308 // Note the we use the names used by the CommandProcessor309 seleneseMethods.put("addLocationStrategy", new AddLocationStrategy(elementFinder));310 seleneseMethods.put("addSelection", new AddSelection(javascriptLibrary, elementFinder));311 seleneseMethods.put("altKeyDown", new AltKeyDown(keyState));312 seleneseMethods.put("altKeyUp", new AltKeyUp(keyState));313 seleneseMethods.put("assignId", new AssignId(javascriptLibrary, elementFinder));314 seleneseMethods.put("attachFile", new AttachFile(elementFinder));315 seleneseMethods.put("captureScreenshotToString", new CaptureScreenshotToString());316 seleneseMethods.put("click", new Click(alertOverride, elementFinder));317 seleneseMethods.put("check", new Check(alertOverride, elementFinder));318 seleneseMethods.put("chooseCancelOnNextConfirmation", new SetNextConfirmationState(false));319 seleneseMethods.put("chooseOkOnNextConfirmation", new SetNextConfirmationState(true));320 seleneseMethods.put("close", new Close());321 seleneseMethods.put("createCookie", new CreateCookie());322 seleneseMethods.put("controlKeyDown", new ControlKeyDown(keyState));323 seleneseMethods.put("controlKeyUp", new ControlKeyUp(keyState));324 seleneseMethods.put("deleteAllVisibleCookies", new DeleteAllVisibleCookies());325 seleneseMethods.put("deleteCookie", new DeleteCookie());326 seleneseMethods.put("doubleClick", new DoubleClick(elementFinder));327 seleneseMethods.put("dragdrop", new DragAndDrop(elementFinder));328 seleneseMethods.put("dragAndDrop", new DragAndDrop(elementFinder));329 seleneseMethods.put("fireEvent", new FireEvent(elementFinder, javascriptLibrary));330 seleneseMethods.put("focus", new FireNamedEvent(elementFinder, javascriptLibrary, "focus"));331 seleneseMethods.put("getAlert", new GetAlert(alertOverride));332 seleneseMethods.put("getAllButtons", new GetAllButtons());333 seleneseMethods.put("getAllFields", new GetAllFields());334 seleneseMethods.put("getAllLinks", new GetAllLinks());335 seleneseMethods.put("getAllWindowTitles", new GetAllWindowTitles());336 seleneseMethods.put("getAttribute", new GetAttribute(javascriptLibrary, elementFinder));337 seleneseMethods.put("getAttributeFromAllWindows", new GetAttributeFromAllWindows());338 seleneseMethods.put("getBodyText", new GetBodyText());339 seleneseMethods.put("getConfirmation", new GetConfirmation(alertOverride));340 seleneseMethods.put("getCookie", new GetCookie());341 seleneseMethods.put("getCookieByName", new GetCookieByName());342 seleneseMethods.put("getElementHeight", new GetElementHeight(elementFinder));343 seleneseMethods.put("getElementIndex", new GetElementIndex(elementFinder,344 javascriptLibrary));345 seleneseMethods.put("getElementPositionLeft", new GetElementPositionLeft(elementFinder));346 seleneseMethods.put("getElementPositionTop", new GetElementPositionTop(elementFinder));347 seleneseMethods.put("getElementWidth", new GetElementWidth(elementFinder));348 seleneseMethods.put("getEval", new GetEval(scriptMutator));349 seleneseMethods.put("getExpression", new GetExpression());350 seleneseMethods.put("getHtmlSource", new GetHtmlSource());351 seleneseMethods.put("getLocation", new GetLocation());352 seleneseMethods.put("getSelectedId", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "id"));353 seleneseMethods.put("getSelectedIds", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "id"));354 seleneseMethods.put("getSelectedIndex", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "index"));355 seleneseMethods.put("getSelectedIndexes", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "index"));356 seleneseMethods.put("getSelectedLabel", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "text"));357 seleneseMethods.put("getSelectedLabels", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "text"));358 seleneseMethods.put("getSelectedValue", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "value"));359 seleneseMethods.put("getSelectedValues", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "value"));360 seleneseMethods.put("getSelectOptions", new GetSelectOptions(javascriptLibrary, elementFinder));361 seleneseMethods.put("getSpeed", new NoOp("0"));362 seleneseMethods.put("getTable", new GetTable(elementFinder, javascriptLibrary));363 seleneseMethods.put("getText", new GetText(javascriptLibrary, elementFinder));364 seleneseMethods.put("getTitle", new GetTitle());365 seleneseMethods.put("getValue", new GetValue(elementFinder));366 seleneseMethods.put("getXpathCount", new GetXpathCount());367 seleneseMethods.put("goBack", new GoBack());368 seleneseMethods.put("highlight", new Highlight(elementFinder, javascriptLibrary));369 seleneseMethods.put("isAlertPresent", new IsAlertPresent(alertOverride));370 seleneseMethods.put("isChecked", new IsChecked(elementFinder));371 seleneseMethods.put("isConfirmationPresent", new IsConfirmationPresent(alertOverride));372 seleneseMethods.put("isCookiePresent", new IsCookiePresent());373 seleneseMethods.put("isEditable", new IsEditable(elementFinder));374 seleneseMethods.put("isElementPresent", new IsElementPresent(elementFinder));375 seleneseMethods.put("isOrdered", new IsOrdered(elementFinder, javascriptLibrary));376 seleneseMethods.put("isSomethingSelected", new IsSomethingSelected(javascriptLibrary));377 seleneseMethods.put("isTextPresent", new IsTextPresent(javascriptLibrary));378 seleneseMethods.put("isVisible", new IsVisible(elementFinder));379 seleneseMethods.put("keyDown", new KeyEvent(elementFinder, javascriptLibrary, keyState, "doKeyDown"));380 seleneseMethods.put("keyPress", new TypeKeys(alertOverride, elementFinder));381 seleneseMethods.put("keyUp", new KeyEvent(elementFinder, javascriptLibrary, keyState, "doKeyUp"));382 seleneseMethods.put("metaKeyDown", new MetaKeyDown(keyState));383 seleneseMethods.put("metaKeyUp", new MetaKeyUp(keyState));384 seleneseMethods.put("mouseOver", new MouseEvent(elementFinder, javascriptLibrary, "mouseover"));385 seleneseMethods.put("mouseOut", new MouseEvent(elementFinder, javascriptLibrary, "mouseout"));386 seleneseMethods.put("mouseDown", new MouseEvent(elementFinder, javascriptLibrary, "mousedown"));387 seleneseMethods.put("mouseDownAt", new MouseEventAt(elementFinder, javascriptLibrary, "mousedown"));388 seleneseMethods.put("mouseMove", new MouseEvent(elementFinder, javascriptLibrary, "mousemove"));389 seleneseMethods.put("mouseMoveAt", new MouseEventAt(elementFinder, javascriptLibrary, "mousemove"));390 seleneseMethods.put("mouseUp", new MouseEvent(elementFinder, javascriptLibrary, "mouseup"));391 seleneseMethods.put("mouseUpAt", new MouseEventAt(elementFinder, javascriptLibrary, "mouseup"));392 seleneseMethods.put("open", new Open(baseUrl));393 seleneseMethods.put("openWindow", new OpenWindow(new GetEval(scriptMutator)));394 seleneseMethods.put("refresh", new Refresh());395 seleneseMethods.put("removeAllSelections", new RemoveAllSelections(elementFinder));396 seleneseMethods.put("removeSelection", new RemoveSelection(javascriptLibrary, elementFinder));397 seleneseMethods.put("runScript", new RunScript(scriptMutator));398 seleneseMethods.put("select", new SelectOption(alertOverride, javascriptLibrary, elementFinder));399 seleneseMethods.put("selectFrame", new SelectFrame(windows));400 seleneseMethods.put("selectWindow", new SelectWindow(windows));401 seleneseMethods.put("setBrowserLogLevel", new NoOp(null));402 seleneseMethods.put("setContext", new NoOp(null));403 seleneseMethods.put("setSpeed", new NoOp(null));404 seleneseMethods.put("setTimeout", new SetTimeout(timer));405 seleneseMethods.put("shiftKeyDown", new ShiftKeyDown(keyState));406 seleneseMethods.put("shiftKeyUp", new ShiftKeyUp(keyState));407 seleneseMethods.put("submit", new Submit(elementFinder));408 seleneseMethods.put("type", new Type(alertOverride, javascriptLibrary, elementFinder, keyState));409 seleneseMethods.put("typeKeys", new TypeKeys(alertOverride, elementFinder));410 seleneseMethods.put("uncheck", new Uncheck(alertOverride, elementFinder));411 seleneseMethods.put("useXpathLibrary", new NoOp(null));412 seleneseMethods.put("waitForCondition", new WaitForCondition(scriptMutator));413 seleneseMethods.put("waitForFrameToLoad", new NoOp(null));414 seleneseMethods.put("waitForPageToLoad", new WaitForPageToLoad());415 seleneseMethods.put("waitForPopUp", new WaitForPopup(windows));416 seleneseMethods.put("windowFocus", new WindowFocus(javascriptLibrary));417 seleneseMethods.put("windowMaximize", new WindowMaximize(javascriptLibrary));418 }419} ...

Full Screen

Full Screen

Source:SeleneseCommandExecutor.java Github

copy

Full Screen

1/*2Copyright 2007-2009 WebDriver committers3Copyright 2007-2009 Google Inc.45Licensed under the Apache License, Version 2.0 (the "License");6you may not use this file except in compliance with the License.7You may obtain a copy of the License at89 http://www.apache.org/licenses/LICENSE-2.01011Unless required by applicable law or agreed to in writing, software12distributed under the License is distributed on an "AS IS" BASIS,13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14See the License for the specific language governing permissions and15limitations under the License.16*/1718package org.openqa.selenium;1920import com.thoughtworks.selenium.CommandProcessor;21import com.thoughtworks.selenium.DefaultSelenium;22import com.thoughtworks.selenium.HttpCommandProcessor;23import com.thoughtworks.selenium.Selenium;24import com.thoughtworks.selenium.SeleniumException;25import com.google.common.collect.ImmutableMap;2627import org.openqa.selenium.firefox.internal.Executable;28import org.openqa.selenium.internal.selenesedriver.SeleneseFunction;29import org.openqa.selenium.internal.selenesedriver.ClearElement;30import org.openqa.selenium.internal.selenesedriver.ClickElement;31import org.openqa.selenium.internal.selenesedriver.FindElement;32import org.openqa.selenium.internal.selenesedriver.GetCurrentUrl;33import org.openqa.selenium.internal.selenesedriver.GetElementText;34import org.openqa.selenium.internal.selenesedriver.GetElementValue;35import org.openqa.selenium.internal.selenesedriver.GetTagName;36import org.openqa.selenium.internal.selenesedriver.GetTitle;37import org.openqa.selenium.internal.selenesedriver.GetUrl;38import org.openqa.selenium.internal.selenesedriver.NewSession;39import org.openqa.selenium.internal.selenesedriver.QuitSelenium;40import org.openqa.selenium.internal.selenesedriver.GetElementAttribute;41import org.openqa.selenium.internal.selenesedriver.GetPageSource;42import org.openqa.selenium.internal.selenesedriver.IsElementDisplayed;43import org.openqa.selenium.internal.selenesedriver.IsElementEnabled;44import org.openqa.selenium.internal.selenesedriver.IsElementSelected;45import org.openqa.selenium.internal.selenesedriver.SendKeys;46import org.openqa.selenium.internal.selenesedriver.SetElementSelected;47import org.openqa.selenium.internal.selenesedriver.SubmitElement;48import org.openqa.selenium.internal.selenesedriver.ToggleElement;49import org.openqa.selenium.internal.selenesedriver.ExecuteScript;50import org.openqa.selenium.remote.BeanToJsonConverter;51import org.openqa.selenium.remote.Capabilities;52import org.openqa.selenium.remote.Command;53import org.openqa.selenium.remote.CommandExecutor;54import org.openqa.selenium.remote.DesiredCapabilities;55import org.openqa.selenium.remote.JsonToBeanConverter;56import org.openqa.selenium.remote.Response;57import org.openqa.selenium.remote.DriverCommand;58import static org.openqa.selenium.remote.DriverCommand.*;5960import java.io.File;61import java.net.URL;62import java.util.HashMap;63import java.util.Map;6465public class SeleneseCommandExecutor implements CommandExecutor {66 private final Selenium instance;67 private Map<DriverCommand, SeleneseFunction> functions;6869 public SeleneseCommandExecutor(URL seleniumServer, URL remoteAddress, Capabilities capabilities) {70 this(new HttpCommandProcessor(71 seleniumServer.getHost(), seleniumServer.getPort(),72 startCommand(capabilities), remoteAddress.toString()));73 }7475 public SeleneseCommandExecutor(CommandProcessor processor) {76 instance = new DefaultSelenium(processor);7778 prepareCommands();79 }8081 public Response execute(Command command) throws Exception {82 SeleneseFunction function = functions.get(command.getName());83 if (function == null) {84 System.out.println("command.getMethodName() = " + command.getName());85 throw new UnsupportedOperationException("cannot execute: " + command.getName());86 }8788 try {89 Response response = new Response();90 response.setValue(function.apply(instance, command.getParameters()));91 return response;92 } catch (Exception e) {93 return prepareExceptionResponse(e);94 }95 }9697 private Response prepareExceptionResponse(Exception e) throws Exception {98 Response response = new Response();99 response.setError(true);100101 Exception toUse = e;102 if (e instanceof SeleniumException) {103 // World of fragility. *sigh*104 if (e.getMessage().matches("ERROR: Element .+ not found")) {105 toUse = new StaleElementReferenceException(e.getMessage(), e);106 }107 }108109 // It's like a lesson in inefficiency110 Object raw = new JsonToBeanConverter().convert(Map.class, new BeanToJsonConverter().convert(toUse));111 response.setValue(raw);112 return response;113 }114115 private void prepareCommands() {116 functions = ImmutableMap.<DriverCommand, SeleneseFunction>builder()117 .put(CLEAR_ELEMENT, new ClearElement())118 .put(CLICK_ELEMENT, new ClickElement())119 .put(GET_CURRENT_URL, new GetCurrentUrl())120 .put(EXECUTE_SCRIPT, new ExecuteScript())121 .put(FIND_ELEMENT, new FindElement())122 .put(GET, new GetUrl())123 .put(GET_ELEMENT_ATTRIBUTE, new GetElementAttribute())124 .put(GET_ELEMENT_TEXT, new GetElementText())125 .put(GET_ELEMENT_VALUE, new GetElementValue())126 .put(GET_ELEMENT_TAG_NAME, new GetTagName())127 .put(GET_TITLE, new GetTitle())128 .put(IS_ELEMENT_DISPLAYED, new IsElementDisplayed())129 .put(IS_ELEMENT_ENABLED, new IsElementEnabled())130 .put(IS_ELEMENT_SELECTED, new IsElementSelected())131 .put(NEW_SESSION, new NewSession())132 .put(GET_PAGE_SOURCE, new GetPageSource())133 .put(SEND_KEYS_TO_ELEMENT, new SendKeys())134 .put(SET_ELEMENT_SELECTED, new SetElementSelected())135 .put(SUBMIT_ELEMENT, new SubmitElement())136 .put(TOGGLE_ELEMENT, new ToggleElement())137 .put(QUIT, new QuitSelenium())138 .build();139 }140141 private static String startCommand(Capabilities capabilities) {142 String browser = capabilities.getBrowserName();143 if (DesiredCapabilities.firefox().getBrowserName().equals(browser)) {144 String path = new Executable(null).getPath();145 return "*chrome " + path;146 } else if ("safari".equals(browser)) {147 String path = findSafari();148 return "*safari " + path;149 } else if (DesiredCapabilities.chrome().getBrowserName().equals(browser)) {150151 return "*googlechrome /Applications/Google Chrome.app/Contents/MacOS/Google Chrome";152 }153154 throw new IllegalArgumentException(155 "Cannot determine which selenium type to use: " + capabilities.getBrowserName());156 }157158 private static String findSafari() {159 if (Platform.getCurrent().is(Platform.WINDOWS)) {160 File[] locations = new File[] {161 new File("C:\\Program Files (x86)\\Safari\\safari.exe"),162 new File("C:\\Program Files\\Safari\\safari.exe")163 };164165 for (File location : locations) {166 if (location.exists()) {167 return location.getAbsolutePath();168 }169 }170 }171172 return "";173 }174} ...

Full Screen

Full Screen

Source:RemoteWebElement.java Github

copy

Full Screen

1/*2Copyright 2007-2009 WebDriver committers3Copyright 2007-2009 Google Inc.4Licensed under the Apache License, Version 2.0 (the "License");5you may not use this file except in compliance with the License.6You may obtain a copy of the License at7 http://www.apache.org/licenses/LICENSE-2.08Unless required by applicable law or agreed to in writing, software9distributed under the License is distributed on an "AS IS" BASIS,10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11See the License for the specific language governing permissions and12limitations under the License.13*/14package org.openqa.selenium.remote;15import com.google.common.collect.ImmutableMap;16import org.openqa.selenium.By;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.WebElement;19import org.openqa.selenium.internal.FindsByClassName;20import org.openqa.selenium.internal.FindsByCssSelector;21import org.openqa.selenium.internal.FindsById;22import org.openqa.selenium.internal.FindsByLinkText;23import org.openqa.selenium.internal.FindsByName;24import org.openqa.selenium.internal.FindsByTagName;25import org.openqa.selenium.internal.FindsByXPath;26import org.openqa.selenium.internal.WrapsDriver;27import org.openqa.selenium.internal.WrapsElement;28import java.util.List;29import java.util.Map;30public class RemoteWebElement implements WebElement, FindsByLinkText, FindsById, FindsByName,31 FindsByTagName, FindsByClassName, FindsByCssSelector, FindsByXPath, WrapsDriver {32 protected String id;33 protected RemoteWebDriver parent;34 protected RemoteWebDriver.RemoteMouse mouse;35 public void setParent(RemoteWebDriver parent) {36 this.parent = parent;37 mouse = (RemoteWebDriver.RemoteMouse) parent.getMouse();38 }39 public String getId() {40 return id;41 }42 public void setId(String id) {43 this.id = id;44 }45 public void click() {46 execute(DriverCommand.CLICK_ELEMENT, ImmutableMap.of("id", id));47 }48 public void submit() {49 execute(DriverCommand.SUBMIT_ELEMENT, ImmutableMap.of("id", id));50 }51 public String getValue() {52 return (String) execute(DriverCommand.GET_ELEMENT_VALUE, ImmutableMap.of("id", id)).getValue();53 }54 public void sendKeys(CharSequence... keysToSend) {55 execute(DriverCommand.SEND_KEYS_TO_ELEMENT, ImmutableMap.of("id", id, "value", keysToSend));56 }57 public void clear() {58 execute(DriverCommand.CLEAR_ELEMENT, ImmutableMap.of("id", id));59 }60 public String getTagName() {61 return (String) execute(DriverCommand.GET_ELEMENT_TAG_NAME, ImmutableMap.of("id", id)).getValue();62 }63 public String getAttribute(String name) {64 Object value = execute(DriverCommand.GET_ELEMENT_ATTRIBUTE, ImmutableMap.of("id", id, "name", name))65 .getValue();66 if (value == null) {67 return null;68 }69 return String.valueOf(value);70 }71 public boolean toggle() {72 return (Boolean) execute(DriverCommand.TOGGLE_ELEMENT, ImmutableMap.of("id", id)).getValue();73 }74 public boolean isSelected() {75 return (Boolean) execute(DriverCommand.IS_ELEMENT_SELECTED, ImmutableMap.of("id", id)).getValue();76 }77 public void setSelected() {78 execute(DriverCommand.SET_ELEMENT_SELECTED, ImmutableMap.of("id", id));79 }80 public boolean isEnabled() {81 return (Boolean) execute(DriverCommand.IS_ELEMENT_ENABLED, ImmutableMap.of("id", id)).getValue();82 }83 public String getText() {84 Response response = execute(DriverCommand.GET_ELEMENT_TEXT, ImmutableMap.of("id", id));85 return (String) response.getValue();86 }87 public List<WebElement> findElements(By by) {88 return by.findElements(this);89 }90 public WebElement findElement(By by) {91 return by.findElement(this);92 }93 protected WebElement findElement(String using, String value) {94 Response response = execute(DriverCommand.FIND_CHILD_ELEMENT,95 ImmutableMap.of("id", id, "using", using, "value", value));96 return (WebElement) response.getValue();97 }98 @SuppressWarnings("unchecked")99 protected List<WebElement> findElements(String using, String value) {100 Response response = execute(DriverCommand.FIND_CHILD_ELEMENTS,101 ImmutableMap.of("id", id, "using", using, "value", value));102 return (List<WebElement>) response.getValue();103 }104 public WebElement findElementById(String using) {105 return findElement("id", using);106 }107 public List<WebElement> findElementsById(String using) {108 return findElements("id", using);109 }110 public WebElement findElementByLinkText(String using) {111 return findElement("link text", using);112 }113 public List<WebElement> findElementsByLinkText(String using) {114 return findElements("link text", using);115 }116 public WebElement findElementByName(String using) {117 return findElement("name", using);118 }119 public List<WebElement> findElementsByName(String using) {120 return findElements("name", using);121 }122 public WebElement findElementByClassName(String using) {123 return findElement("class name", using);124 }125 public List<WebElement> findElementsByClassName(String using) {126 return findElements("class name", using);127 }128 public WebElement findElementByCssSelector(String using) {129 return findElement("css selector", using);130 }131 public List<WebElement> findElementsByCssSelector(String using) {132 return findElements("css selector", using);133 }134 public WebElement findElementByXPath(String using) {135 return findElement("xpath", using);136 }137 public List<WebElement> findElementsByXPath(String using) {138 return findElements("xpath", using);139 }140 public WebElement findElementByPartialLinkText(String using) {141 return findElement("partial link text", using);142 }143 public List<WebElement> findElementsByPartialLinkText(String using) {144 return findElements("partial link text", using);145 }146 public WebElement findElementByTagName(String using) {147 return findElement("tag name", using);148 }149 public List<WebElement> findElementsByTagName(String using) {150 return findElements("tag name", using);151 }152 protected Response execute(String command, Map<String, ?> parameters) {153 return parent.execute(command, parameters);154 }155 @Override156 public boolean equals(Object obj) {157 if (!(obj instanceof WebElement)) {158 return false;159 }160 WebElement other = (WebElement) obj;161 if (other instanceof WrapsElement) {162 other = ((WrapsElement) obj).getWrappedElement();163 }164 if (!(other instanceof RemoteWebElement)) {165 return false;166 }167 Response response = execute(DriverCommand.ELEMENT_EQUALS,168 ImmutableMap.of("id", id, "other", ((RemoteWebElement) other).id));169 Object value = response.getValue();170 return value != null && value instanceof Boolean && (Boolean) value;171 }172 /**173 * @return This element's hash code, which is a hash of its internal opaque ID.174 */175 @Override176 public int hashCode() {177 return id.hashCode();178 }179 /* (non-Javadoc)180 * @see org.openqa.selenium.internal.WrapsDriver#getWrappedDriver()181 */182 public WebDriver getWrappedDriver() {183 return parent;184 }185}...

Full Screen

Full Screen

Source:DefaultGenericMobileElement.java Github

copy

Full Screen

1/*2 * Licensed under the Apache License, Version 2.0 (the "License");3 * you may not use this file except in compliance with the License.4 * See the NOTICE file distributed with this work for additional5 * information regarding copyright ownership.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package io.appium.java_client;17import com.google.common.collect.ImmutableMap;18import org.openqa.selenium.By;19import org.openqa.selenium.WebDriverException;20import org.openqa.selenium.WebElement;21import org.openqa.selenium.internal.FindsByClassName;22import org.openqa.selenium.internal.FindsByCssSelector;23import org.openqa.selenium.internal.FindsById;24import org.openqa.selenium.internal.FindsByLinkText;25import org.openqa.selenium.internal.FindsByName;26import org.openqa.selenium.internal.FindsByTagName;27import org.openqa.selenium.internal.FindsByXPath;28import org.openqa.selenium.remote.RemoteWebElement;29import org.openqa.selenium.remote.Response;30import java.util.List;31import java.util.Map;32@SuppressWarnings({"unchecked", "rawtypes"})33abstract class DefaultGenericMobileElement<T extends WebElement> extends RemoteWebElement34 implements FindsByClassName,35 FindsByCssSelector, FindsById,36 FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByFluentSelector<T>, FindsByAccessibilityId<T>,37 ExecutesMethod, TouchableElement<T> {38 @Override public Response execute(String driverCommand, Map<String, ?> parameters) {39 return super.execute(driverCommand, parameters);40 }41 @Override public Response execute(String command) {42 return super.execute(command, ImmutableMap.<String, Object>of());43 }44 @Override public List findElements(By by) {45 return super.findElements(by);46 }47 @Override public List findElements(String by, String using) {48 return super.findElements(by, using);49 }50 @Override public T findElement(By by) {51 return (T) super.findElement(by);52 }53 @Override public T findElement(String by, String using) {54 return (T) super.findElement(by, using);55 }56 @Override public List findElementsById(String id) {57 return super.findElementsById(id);58 }59 @Override public T findElementById(String id) {60 return (T) super.findElementById(id);61 }62 /**63 * @throws WebDriverException his method doesn't work against native app UI.64 */65 public T findElementByLinkText(String using) throws WebDriverException {66 return (T) super.findElementByLinkText(using);67 }68 /**69 * @throws WebDriverException This method doesn't work against native app UI.70 */71 public List findElementsByLinkText(String using) throws WebDriverException {72 return super.findElementsByLinkText(using);73 }74 /**75 * @throws WebDriverException his method doesn't work against native app UI.76 */77 public T findElementByPartialLinkText(String using) throws WebDriverException {78 return (T) super.findElementByPartialLinkText(using);79 }80 /**81 * @throws WebDriverException This method doesn't work against native app UI.82 */83 public List findElementsByPartialLinkText(String using) throws WebDriverException {84 return super.findElementsByPartialLinkText(using);85 }86 public T findElementByTagName(String using) {87 return (T) super.findElementByTagName(using);88 }89 public List findElementsByTagName(String using) {90 return super.findElementsByTagName(using);91 }92 public T findElementByName(String using) {93 return (T) super.findElementByName(using);94 }95 public List findElementsByName(String using) {96 return super.findElementsByName(using);97 }98 public T findElementByClassName(String using) {99 return (T) super.findElementByClassName(using);100 }101 public List findElementsByClassName(String using) {102 return super.findElementsByClassName(using);103 }104 /**105 * @throws WebDriverException his method doesn't work against native app UI.106 */107 public T findElementByCssSelector(String using) throws WebDriverException {108 return (T) super.findElementByCssSelector(using);109 }110 /**111 * @throws WebDriverException This method doesn't work against native app UI.112 */113 public List findElementsByCssSelector(String using) throws WebDriverException {114 return super.findElementsByCssSelector(using);115 }116 public T findElementByXPath(String using) {117 return (T) super.findElementByXPath(using);118 }119 public List findElementsByXPath(String using) {120 return super.findElementsByXPath(using);121 }122 /**123 * @throws WebDriverException because it may not work against native app UI.124 */125 public void submit() throws WebDriverException {126 super.submit();127 }128 /**129 * @throws WebDriverException because it may not work against native app UI.130 */131 public String getCssValue(String propertyName) throws WebDriverException {132 return super.getCssValue(propertyName);133 }134}...

Full Screen

Full Screen

Source:MobileDriver.java Github

copy

Full Screen

1/*2 * Licensed under the Apache License, Version 2.0 (the "License");3 * you may not use this file except in compliance with the License.4 * See the NOTICE file distributed with this work for additional5 * information regarding copyright ownership.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.mengge;17import org.openqa.selenium.By;18import org.openqa.selenium.ContextAware;19import org.openqa.selenium.Rotatable;20import org.openqa.selenium.WebDriver;21import org.openqa.selenium.WebElement;22import org.openqa.selenium.html5.LocationContext;23import org.openqa.selenium.internal.FindsByClassName;24import org.openqa.selenium.internal.FindsByCssSelector;25import org.openqa.selenium.internal.FindsById;26import org.openqa.selenium.internal.FindsByLinkText;27import org.openqa.selenium.internal.FindsByName;28import org.openqa.selenium.internal.FindsByTagName;29import org.openqa.selenium.internal.FindsByXPath;30import org.openqa.selenium.remote.Response;31import java.util.List;32import java.util.Map;33public interface MobileDriver<T extends WebElement> extends WebDriver, PerformsTouchActions, ContextAware, Rotatable,34 FindsByAccessibilityId<T>, LocationContext, DeviceActionShortcuts, TouchShortcuts,35 InteractsWithFiles, InteractsWithApps, HasAppStrings, FindsByClassName, FindsByCssSelector, FindsById,36 FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath {37 Response execute(String driverCommand, Map<String, ?> parameters);38 List<T> findElements(By by);39 T findElement(By by);40 T findElementByClassName(String className);41 List<T> findElementsByClassName(String className);42 T findElementByCssSelector(String cssSelector);43 List<T> findElementsByCssSelector(String cssSelector);44 T findElementById(String id);45 List<T> findElementsById(String id);46 T findElementByLinkText(String linkText);47 List<T> findElementsByLinkText(String linkText);48 T findElementByPartialLinkText(String partialLinkText);49 List<T> findElementsByPartialLinkText(String partialLinkText);50 T findElementByName(String name);51 List<T> findElementsByName(String name);52 T findElementByTagName(String tagName);53 List<T> findElementsByTagName(String tagName);54 T findElementByXPath(String xPath);55 List<T> findElementsByXPath(String xPath);56}...

Full Screen

Full Screen

map

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.By2import org.openqa.selenium.WebDriver3import org.openqa.selenium.WebElement4import org.openqa.selenium.chrome.ChromeDriver5import org.openqa.selenium.internal.Either6def driver = new ChromeDriver()7driver.findElement(By.name("q")).sendKeys("groovy")8driver.findElement(By.name("btnK")).click()9def driver = new ChromeDriver()10driver.findElement(By.name("q")).sendKeys("groovy")11driver.findElement(By.name("btnK")).click()12def driver = new ChromeDriver()13driver.findElement(By.name("q")).sendKeys("groovy")14driver.findElement(By.name("btnK")).click()15def driver = new ChromeDriver()16driver.findElement(By.name("q")).sendKeys("groovy")17driver.findElement(By.name("btnK")).click()18def driver = new ChromeDriver()19driver.findElement(By.name("q")).sendKeys("groovy")20driver.findElement(By.name("btnK")).click()21def driver = new ChromeDriver()22driver.findElement(By.name("q")).sendKeys

Full Screen

Full Screen

map

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.internal.Either2def convertToEitherWebElement(Either<String, String> either) {3 return either.map({ it -> driver.findElement(By.id(it)) })4}5import org.openqa.selenium.internal.Either6def convertToEitherWebElement(Either<String, String> either) {7 return either.map({ it -> driver.findElement(By.id(it)) })8}9import org.openqa.selenium.internal.Either10def convertToEitherWebElement(Either<String, String> either) {11 return either.map({ it -> driver.findElement(By.id(it)) })12}13import org.openqa.selenium.internal.Either14def convertToEitherWebElement(Either<String, String> either) {15 return either.map({ it -> driver.findElement(By.id(it)) })16}17import org.openqa.selenium.internal.Either18def convertToEitherWebElement(Either<String, String> either) {19 return either.map({ it -> driver.findElement(By.id(it)) })20}21import org.openqa.selenium.internal.Either22def convertToEitherWebElement(Either<String, String> either) {23 return either.map({ it -> driver.findElement(By.id(it)) })24}25import org.openqa.selenium.internal.Either26def convertToEitherWebElement(Either<String, String> either) {27 return either.map({ it -> driver.findElement(By.id(it)) })28}

Full Screen

Full Screen

map

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.support.ui.ExpectedConditions2import org.openqa.selenium.support.ui.WebDriverWait3import org.openqa.selenium.support.ui.ExpectedCondition4import org.openqa.selenium.By5import org.openqa.selenium.WebDriver6import org.openqa.selenium.WebElement7import org.openqa.selenium.chrome.ChromeDriver8import org.openqa.selenium.firefox.FirefoxDriver9import org.openqa.selenium.firefox.FirefoxProfile10import org.openqa.selenium.firefox.internal.ProfilesIni11import org.openqa.selenium.interactions.Actions12import org.openqa.selenium.internal.Either13import org.openqa.selenium.remote.DesiredCapabilities14import org.openqa.selenium.support.ui.ExpectedConditions15import org.openqa.selenium.support.ui.WebDriverWait16import org.openqa.selenium.support.ui.ExpectedCondition17import org.openqa.selenium.By18import org.openqa.selenium.WebDriver19import org.openqa.selenium.WebElement20import org.openqa.selenium.chrome.ChromeDriver21import org.openqa.selenium.firefox.FirefoxDriver22import org.openqa.selenium.firefox.FirefoxProfile23import org.openqa.selenium.firefox.internal.ProfilesIni24import org.openqa.selenium.interactions.Actions25import org.openqa.selenium.internal.Either26import org.openqa.selenium.remote.DesiredCapabilities27import org.openqa.selenium.support.ui.ExpectedConditions28import org.openqa.selenium.support.ui.WebDriverWait29import org.openqa.selenium.support.ui.ExpectedCondition30import org.openqa.selenium.By31import org.openqa.selenium.WebDriver32import org.openqa.selenium.WebElement33import org.openqa.selenium.chrome.ChromeDriver34import org.openqa.selenium.firefox.FirefoxDriver35import org.openqa.selenium.firefox.FirefoxProfile36import org.openqa.selenium.firefox.internal.ProfilesIni37import org.openqa.selenium.interactions.Actions38import org.openqa.selenium.internal.Either39import org.openqa.selenium.remote.DesiredCapabilities40import org.openqa.selenium.support.ui.ExpectedConditions41import org.openqa.selenium.support.ui.WebDriverWait42import org.openqa.selenium.support.ui.ExpectedCondition43import org.openqa.selenium.By44import org.openqa.selenium.WebDriver45import org.openqa.selenium.WebElement46import org.openqa.selenium.chrome.ChromeDriver47import org.openqa.selenium.firefox.FirefoxDriver48import org.openqa.selenium.firefox.FirefoxProfile49import org.openqa.selenium.firefox.internal.ProfilesIni50import org.openqa.selenium.interactions.Actions51import org.openqa.selenium.internal.Either52import org.openqa.selenium.remote.DesiredCapabilities53import org.openqa.selenium.support.ui.ExpectedConditions54import org.openqa.selenium.support.ui.WebDriver

Full Screen

Full Screen

Selenium 4 Tutorial:

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

Chapters:

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

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

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

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

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

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

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

Selenium 101 certifications:

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

Run Selenium automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful