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

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

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.base.Supplier;21import com.google.common.collect.Maps;2223import com.thoughtworks.selenium.CommandProcessor;24import com.thoughtworks.selenium.SeleniumException;2526import org.openqa.selenium.internal.WrapsDriver;27import org.openqa.selenium.internal.seleniumemulation.AddLocationStrategy;28import org.openqa.selenium.internal.seleniumemulation.AddSelection;29import org.openqa.selenium.internal.seleniumemulation.AlertOverride;30import org.openqa.selenium.internal.seleniumemulation.AltKeyDown;31import org.openqa.selenium.internal.seleniumemulation.AltKeyUp;32import org.openqa.selenium.internal.seleniumemulation.AssignId;33import org.openqa.selenium.internal.seleniumemulation.AttachFile;34import org.openqa.selenium.internal.seleniumemulation.CaptureScreenshotToString;35import org.openqa.selenium.internal.seleniumemulation.Check;36import org.openqa.selenium.internal.seleniumemulation.Click;37import org.openqa.selenium.internal.seleniumemulation.Close;38import org.openqa.selenium.internal.seleniumemulation.CompoundMutator;39import org.openqa.selenium.internal.seleniumemulation.ControlKeyDown;40import org.openqa.selenium.internal.seleniumemulation.ControlKeyUp;41import org.openqa.selenium.internal.seleniumemulation.CreateCookie;42import org.openqa.selenium.internal.seleniumemulation.DeleteAllVisibleCookies;43import org.openqa.selenium.internal.seleniumemulation.DeleteCookie;44import org.openqa.selenium.internal.seleniumemulation.DoubleClick;45import org.openqa.selenium.internal.seleniumemulation.DragAndDrop;46import org.openqa.selenium.internal.seleniumemulation.DragAndDropToObject;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 private void assertDriverSupportsJavascript(WebDriver driver) {285 // TODO(simon): We're starting to need a "describe" interface for checks286 // like this.287 if (!(driver instanceof JavascriptExecutor)) {288 throw new IllegalStateException("Driver instance must support JS.");289 }290291 if (!((JavascriptExecutor) driver).isJavascriptEnabled()) {292 throw new IllegalStateException("JS support must be enabled.");293 }294 }295296 private void setUpMethodMap() {297 JavascriptLibrary javascriptLibrary = new JavascriptLibrary();298 ElementFinder elementFinder = new ElementFinder(javascriptLibrary);299 KeyState keyState = new KeyState();300301 AlertOverride alertOverride = new AlertOverride();302 Windows windows = new Windows(driver);303304 // Note the we use the names used by the CommandProcessor305 seleneseMethods.put("addLocationStrategy", new AddLocationStrategy(elementFinder));306 seleneseMethods.put("addSelection", new AddSelection(javascriptLibrary, elementFinder));307 seleneseMethods.put("altKeyDown", new AltKeyDown(keyState));308 seleneseMethods.put("altKeyUp", new AltKeyUp(keyState));309 seleneseMethods.put("assignId", new AssignId(javascriptLibrary, elementFinder));310 seleneseMethods.put("attachFile", new AttachFile(elementFinder));311 seleneseMethods.put("captureScreenshotToString", new CaptureScreenshotToString());312 seleneseMethods.put("click", new Click(alertOverride, elementFinder));313 seleneseMethods.put("check", new Check(alertOverride, elementFinder));314 seleneseMethods.put("chooseCancelOnNextConfirmation", new SetNextConfirmationState(false));315 seleneseMethods.put("chooseOkOnNextConfirmation", new SetNextConfirmationState(true));316 seleneseMethods.put("close", new Close());317 seleneseMethods.put("createCookie", new CreateCookie());318 seleneseMethods.put("controlKeyDown", new ControlKeyDown(keyState));319 seleneseMethods.put("controlKeyUp", new ControlKeyUp(keyState));320 seleneseMethods.put("deleteAllVisibleCookies", new DeleteAllVisibleCookies());321 seleneseMethods.put("deleteCookie", new DeleteCookie());322 seleneseMethods.put("doubleClick", new DoubleClick(elementFinder));323 seleneseMethods.put("dragdrop", new DragAndDrop(elementFinder));324 seleneseMethods.put("dragAndDrop", new DragAndDrop(elementFinder));325 seleneseMethods.put("dragAndDropToObject", new DragAndDropToObject(elementFinder));326 seleneseMethods.put("fireEvent", new FireEvent(elementFinder, javascriptLibrary));327 seleneseMethods.put("focus", new FireNamedEvent(elementFinder, javascriptLibrary, "focus"));328 seleneseMethods.put("getAlert", new GetAlert(alertOverride));329 seleneseMethods.put("getAllButtons", new GetAllButtons());330 seleneseMethods.put("getAllFields", new GetAllFields());331 seleneseMethods.put("getAllLinks", new GetAllLinks());332 seleneseMethods.put("getAllWindowTitles", new GetAllWindowTitles());333 seleneseMethods.put("getAttribute", new GetAttribute(javascriptLibrary, elementFinder));334 seleneseMethods.put("getAttributeFromAllWindows", new GetAttributeFromAllWindows());335 seleneseMethods.put("getBodyText", new GetBodyText());336 seleneseMethods.put("getConfirmation", new GetConfirmation(alertOverride));337 seleneseMethods.put("getCookie", new GetCookie());338 seleneseMethods.put("getCookieByName", new GetCookieByName());339 seleneseMethods.put("getElementHeight", new GetElementHeight(elementFinder));340 seleneseMethods.put("getElementIndex", new GetElementIndex(elementFinder,341 javascriptLibrary));342 seleneseMethods.put("getElementPositionLeft", new GetElementPositionLeft(elementFinder));343 seleneseMethods.put("getElementPositionTop", new GetElementPositionTop(elementFinder));344 seleneseMethods.put("getElementWidth", new GetElementWidth(elementFinder));345 seleneseMethods.put("getEval", new GetEval(scriptMutator));346 seleneseMethods.put("getExpression", new GetExpression());347 seleneseMethods.put("getHtmlSource", new GetHtmlSource());348 seleneseMethods.put("getLocation", new GetLocation());349 seleneseMethods.put("getSelectedId", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "id"));350 seleneseMethods.put("getSelectedIds", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "id"));351 seleneseMethods.put("getSelectedIndex", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "index"));352 seleneseMethods.put("getSelectedIndexes", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "index"));353 seleneseMethods.put("getSelectedLabel", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "text"));354 seleneseMethods.put("getSelectedLabels", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "text"));355 seleneseMethods.put("getSelectedValue", new FindFirstSelectedOptionProperty(javascriptLibrary, elementFinder, "value"));356 seleneseMethods.put("getSelectedValues", new FindSelectedOptionProperties(javascriptLibrary, elementFinder, "value"));357 seleneseMethods.put("getSelectOptions", new GetSelectOptions(javascriptLibrary, elementFinder));358 seleneseMethods.put("getSpeed", new NoOp("0"));359 seleneseMethods.put("getTable", new GetTable(elementFinder, javascriptLibrary));360 seleneseMethods.put("getText", new GetText(javascriptLibrary, elementFinder));361 seleneseMethods.put("getTitle", new GetTitle());362 seleneseMethods.put("getValue", new GetValue(elementFinder));363 seleneseMethods.put("getXpathCount", new GetXpathCount());364 seleneseMethods.put("goBack", new GoBack());365 seleneseMethods.put("highlight", new Highlight(elementFinder, javascriptLibrary));366 seleneseMethods.put("isAlertPresent", new IsAlertPresent(alertOverride));367 seleneseMethods.put("isChecked", new IsChecked(elementFinder));368 seleneseMethods.put("isConfirmationPresent", new IsConfirmationPresent(alertOverride));369 seleneseMethods.put("isCookiePresent", new IsCookiePresent());370 seleneseMethods.put("isEditable", new IsEditable(elementFinder));371 seleneseMethods.put("isElementPresent", new IsElementPresent(elementFinder));372 seleneseMethods.put("isOrdered", new IsOrdered(elementFinder, javascriptLibrary));373 seleneseMethods.put("isSomethingSelected", new IsSomethingSelected(javascriptLibrary));374 seleneseMethods.put("isTextPresent", new IsTextPresent(javascriptLibrary));375 seleneseMethods.put("isVisible", new IsVisible(elementFinder));376 seleneseMethods.put("keyDown", new KeyEvent(elementFinder, javascriptLibrary, keyState, "doKeyDown"));377 seleneseMethods.put("keyPress", new TypeKeys(alertOverride, elementFinder));378 seleneseMethods.put("keyUp", new KeyEvent(elementFinder, javascriptLibrary, keyState, "doKeyUp"));379 seleneseMethods.put("metaKeyDown", new MetaKeyDown(keyState));380 seleneseMethods.put("metaKeyUp", new MetaKeyUp(keyState));381 seleneseMethods.put("mouseOver", new MouseEvent(elementFinder, javascriptLibrary, "mouseover"));382 seleneseMethods.put("mouseOut", new MouseEvent(elementFinder, javascriptLibrary, "mouseout"));383 seleneseMethods.put("mouseDown", new MouseEvent(elementFinder, javascriptLibrary, "mousedown"));384 seleneseMethods.put("mouseDownAt", new MouseEventAt(elementFinder, javascriptLibrary, "mousedown"));385 seleneseMethods.put("mouseMove", new MouseEvent(elementFinder, javascriptLibrary, "mousemove"));386 seleneseMethods.put("mouseMoveAt", new MouseEventAt(elementFinder, javascriptLibrary, "mousemove"));387 seleneseMethods.put("mouseUp", new MouseEvent(elementFinder, javascriptLibrary, "mouseup"));388 seleneseMethods.put("mouseUpAt", new MouseEventAt(elementFinder, javascriptLibrary, "mouseup"));389 seleneseMethods.put("open", new Open(baseUrl));390 seleneseMethods.put("openWindow", new OpenWindow(new GetEval(scriptMutator)));391 seleneseMethods.put("refresh", new Refresh());392 seleneseMethods.put("removeAllSelections", new RemoveAllSelections(elementFinder));393 seleneseMethods.put("removeSelection", new RemoveSelection(javascriptLibrary, elementFinder));394 seleneseMethods.put("runScript", new RunScript(scriptMutator));395 seleneseMethods.put("select", new SelectOption(alertOverride, javascriptLibrary, elementFinder));396 seleneseMethods.put("selectFrame", new SelectFrame(windows));397 seleneseMethods.put("selectWindow", new SelectWindow(windows));398 seleneseMethods.put("setBrowserLogLevel", new NoOp(null));399 seleneseMethods.put("setContext", new NoOp(null));400 seleneseMethods.put("setSpeed", new NoOp(null));401 seleneseMethods.put("setTimeout", new SetTimeout(timer));402 seleneseMethods.put("shiftKeyDown", new ShiftKeyDown(keyState));403 seleneseMethods.put("shiftKeyUp", new ShiftKeyUp(keyState));404 seleneseMethods.put("submit", new Submit(elementFinder));405 seleneseMethods.put("type", new Type(alertOverride, javascriptLibrary, elementFinder, keyState));406 seleneseMethods.put("typeKeys", new TypeKeys(alertOverride, elementFinder));407 seleneseMethods.put("uncheck", new Uncheck(alertOverride, elementFinder));408 seleneseMethods.put("useXpathLibrary", new NoOp(null));409 seleneseMethods.put("waitForCondition", new WaitForCondition(scriptMutator));410 seleneseMethods.put("waitForFrameToLoad", new NoOp(null));411 seleneseMethods.put("waitForPageToLoad", new WaitForPageToLoad());412 seleneseMethods.put("waitForPopUp", new WaitForPopup(windows));413 seleneseMethods.put("windowFocus", new WindowFocus(javascriptLibrary));414 seleneseMethods.put("windowMaximize", new WindowMaximize(javascriptLibrary));415 }416} ...

Full Screen

Full Screen

Source:AndroidWebElement.java Github

copy

Full Screen

...266 public void dragAndDropOn(AndroidWebElement element) {267 throw new UnsupportedOperationException("Action not supported.");268 }269 /**270 * Where on the page is the top left-hand corner of the rendered element? it's part of271 * RenderedWebElement272 *273 * @return A point, containing the location of the top left-hand corner of the element274 */275 public Point getLocation() {276 Map<String, Long> map = (Map<String, Long>) driver.executeAtom(277 AndroidAtoms.GET_TOP_LEFT_COORDINATES.getValue(), this);278 return new Point(map.get("x").intValue(), map.get("y").intValue());279 }280 /**281 * @return a {@link Point} where x is the width, and y is the height.282 */283 public Dimension getSize() {284 Map<String, Long> map = (Map<String, Long>) driver.executeAtom(285 AndroidAtoms.GET_SIZE.getValue(), this);286 return new Dimension(map.get("width").intValue(),287 map.get("height").intValue());...

Full Screen

Full Screen

Source:TouchableElement.java Github

copy

Full Screen

...121 * swiping should be started. If direction is UP then122 * this is offset from the bottom of the element.123 * If direction is DOWN then this is offset from the top of124 * the element. If direction is RIGHT then this is offset from125 * the left border of the element. If direction is LEFT then126 * this is offset from the right border of the element.127 * @param offsetFromEndBorder is the offset from the border of the element where128 * the swiping should be finished. If direction is UP then129 * this is offset from the top of the element.130 * If direction is DOWN then this is offset from the bottom131 * of the element. If direction is RIGHT then132 * this is offset from the right border of the element.133 * If direction is LEFT then this is offset from the134 * left border of the element.135 * @param duration amount of time in milliseconds for the entire swipe action to136 * take.137 * @throws IllegalCoordinatesException when resulted coordinates are out of the138 * element borders or disagree with the given direction.139 */140 void swipe(SwipeElementDirection direction, int offsetFromStartBorder, int offsetFromEndBorder,141 int duration) throws IllegalCoordinatesException;142} ...

Full Screen

Full Screen

Source:SessionNotCreated.java Github

copy

Full Screen

...43 try (Span span = newSpanAsChildOf(tracer, req, "sessionqueue.created_bad")) {44 HTTP_REQUEST.accept(span, req);45 String message = Contents.fromJson(req, String.class);46 SessionNotCreatedException exception = new SessionNotCreatedException(message);47 queue.complete(requestId, Either.left(exception));48 HttpResponse res = new HttpResponse();49 HTTP_RESPONSE.accept(span, res);50 return res;51 }52 }53}...

Full Screen

Full Screen

Source:NewNodeSession.java Github

copy

Full Screen

...45 HashMap<String, Object> response = new HashMap<>();46 if (result.isRight()) {47 response.put("sessionResponse", result.right());48 } else {49 WebDriverException exception = result.left();50 response.put("exception", ImmutableMap.of(51 "error", exception.getClass(),52 "message", exception.getMessage()));53 }54 value.put("value", response);55 return new HttpResponse().setContent(asJson(value));56 }57}...

Full Screen

Full Screen

Source:CreateSession.java Github

copy

Full Screen

...40 HttpResponse res = new HttpResponse();41 Map<String, Object> value;42 if (result.isLeft()) {43 res.setStatus(HTTP_INTERNAL_ERROR);44 value = singletonMap("value", result.left());45 } else {46 value = singletonMap("value", result.right());47 }48 res.setContent(Contents.asJson(value));49 return res;50 }51}...

Full Screen

Full Screen

Source:EitherAssert.java Github

copy

Full Screen

...8 public EitherAssert<A, B> isLeft() {9 isNotNull();10 if (actual.isRight()) {11 failWithMessage(12 "Expected Either to be left but it is right: %s", actual.right());13 }14 return this;15 }16 public EitherAssert<A, B> isRight() {17 isNotNull();18 if (actual.isLeft()) {19 failWithMessage(20 "Expected Either to be right but it is left: %s", actual.left());21 }22 return this;23 }24}...

Full Screen

Full Screen

left

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.internal.Either;2import org.openqa.selenium.internal.Either.Left;3import org.openqa.selenium.internal.Either.Right;4public class EitherExample {5 public static void main(String[] args) {6 Either<String, Integer> either = new Left<>("left");7 System.out.println(either.left().get());8 either = new Right<>(1);9 System.out.println(either.right().get());10 }11}

Full Screen

Full Screen

left

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.internal.Either;2import org.openqa.selenium.internal.Either.Left;3import org.openqa.selenium.internal.Either.Right;4public class EitherExample {5 public static void main(String[] args) {6 Either<String, Integer> either = Either.left("left");7 Either<String, Integer> either1 = Either.right(10);8 System.out.println("isLeft(): " + either.isLeft());9 System.out.println("isRight(): " + either.isRight());10 System.out.println("left(): " + either.left());11 System.out.println("right(): " + either.right());12 System.out.println("isLeft(): " + either1.isLeft());13 System.out.println("isRight(): " + either1.isRight());14 System.out.println("left(): " + either1.left());15 System.out.println("right(): " + either1.right());16 }17}18isLeft(): true19isRight(): false20left(): left21right(): null22isLeft(): false23isRight(): true24left(): null25right(): 1026import com.google.common.util.concurrent.Either;27import com.google.common.util.concurrent.Either.Left;28import com.google.common.util.concurrent.Either.Right;29public class EitherExample {30 public static void main(String[] args) {31 Either<String, Integer> either = Either.left("left");32 Either<String, Integer> either1 = Either.right(10);33 System.out.println("isLeft(): " + either.isLeft());34 System.out.println("isRight(): " + either.isRight());35 System.out.println("left(): " + either.left());36 System.out.println("right(): " + either.right());37 System.out.println("isLeft(): " + either1.isLeft());38 System.out.println("isRight(): " + either1.isRight());39 System.out.println("left(): " + either1.left());40 System.out.println("right(): " + either1.right());41 }42}43isLeft(): true44isRight(): false45left(): left46right(): null47isLeft(): false48isRight(): true49left(): null50right(): 10

Full Screen

Full Screen

left

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.internal.Either;2import org.openqa.selenium.internal.Either.Left;3import org.openqa.selenium.internal.Either.Right;4public class EitherExample {5 public static void main(String[] args) {6 Either<Integer, String> either = new Either<Integer, String>(new Right<Integer>(1));7 System.out.println("Either is Right: " + either.isRight());8 System.out.println("Either is Left: " + either.isLeft());9 System.out.println("Either value: " + either.right().get());10 either = new Either<Integer, String>(new Left<String>("Left"));11 System.out.println("Either is Right: " + either.isRight());12 System.out.println("Either is Left: " + either.isLeft());13 System.out.println("Either value: " + either.left().get());14 }15}16import org.openqa.selenium.internal.Either;17import org.openqa.selenium.internal.Either.Left;18import org.openqa.selenium.internal.Either.Right;19public class EitherMethodExample {20 public static void main(String[] args) {21 Either<Integer, String> either = getEither(true);22 System.out.println("Either is Right: " + either.isRight());23 System.out.println("Either is Left: " + either.isLeft());24 System.out.println("Either value: " + either.right().get());25 either = getEither(false);26 System.out.println("Either is Right: " + either.isRight());27 System.out.println("Either is Left: " + either.isLeft());28 System.out.println("Either value: " + either.left().get());29 }30 public static Either<Integer, String> getEither(boolean isRight) {

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