How to use getName method of org.openqa.selenium.interactions.PointerInput class

Best Selenium code snippet using org.openqa.selenium.interactions.PointerInput.getName

Source:Actions.java Github

copy

Full Screen

...39 * Implements the builder pattern: Builds a CompositeAction containing all actions specified by the40 * method calls.41 */42public class Actions {43 private final static Logger LOG = Logger.getLogger(Actions.class.getName());44 private final WebDriver driver;45 // W3C46 private final Map<InputSource, Sequence> sequences = new HashMap<>();47 private final PointerInput defaultMouse = new PointerInput(MOUSE, "default mouse");48 private final KeyInput defaultKeyboard = new KeyInput("default keyboard");49 // JSON-wire protocol50 private final Keyboard jsonKeyboard;51 private final Mouse jsonMouse;52 protected CompositeAction action = new CompositeAction();53 public Actions(WebDriver driver) {54 this.driver = Preconditions.checkNotNull(driver);55 if (driver instanceof HasInputDevices) {56 HasInputDevices deviceOwner = (HasInputDevices) driver;57 this.jsonKeyboard = deviceOwner.getKeyboard();...

Full Screen

Full Screen

Source:ReplayAction.java Github

copy

Full Screen

...93 // corrects bug of waitElementPresent which threw a SessionNotFoundError because driver reference were not94 // updated before searching element (it used the driver reference of an old test session)95 HtmlElement element = (HtmlElement)joinPoint.getTarget();96 element.setDriver(WebUIDriver.getWebDriver(false));97 String targetName = joinPoint.getTarget().toString();98 99 Instant end = systemClock.instant().plusSeconds(element.getReplayTimeout());100 101 TestAction currentAction = null;102 String methodName = joinPoint.getSignature().getName();103 if (!methodName.equals("getCoordinates")) {104 List<String> pwdToReplace = new ArrayList<>();105 String actionName = String.format("%s on %s %s", methodName, targetName, LogAction.buildArgString(joinPoint, pwdToReplace, new HashMap<>()));106 currentAction = new TestAction(actionName, false, pwdToReplace);107 }108109 // log action before its started. By default, it's OK. Then result may be overwritten if step fails110 // order of steps is the right one (first called is first displayed)111 if (currentAction != null && TestStepManager.getParentTestStep() != null) {112 TestStepManager.getParentTestStep().addAction(currentAction);113 } 114 115 boolean actionFailed = false;116 boolean ignoreFailure = false;117 Throwable currentException = null;118 119 try {120 while (end.isAfter(systemClock.instant())) {121122 // in case we have switched to an iframe for using previous webElement, go to default content123 if (element.getDriver() != null && SeleniumTestsContextManager.isWebTest()) {124 element.getDriver().switchTo().defaultContent(); // TODO: error when clic is done, closing current window125 }126 127 try {128 reply = joinPoint.proceed(joinPoint.getArgs());129 WaitHelper.waitForMilliSeconds(200);130 break;131 } catch (UnhandledAlertException e) {132 throw e;133 } catch (MoveTargetOutOfBoundsException | InvalidElementStateException e) {134 135 // if click has been intercepted, it means element could not be interacted, so allow auto scrolling for further retries136 // to avoid trying always the same method, we try without scrolling, then with scrolling, then without, ...137 138 if (element.isScrollToElementBeforeAction()) {139 element.setScrollToElementBeforeAction(false);140 } else {141 element.setScrollToElementBeforeAction(true);142 }143 } catch (WebDriverException e) { 144 // don't prevent TimeoutException to be thrown when coming from waitForPresent145 // only check that cause is the not found element and not an other error (NoSucheSessionError for example)146 if ((e instanceof TimeoutException 147 && joinPoint.getSignature().getName().equals("waitForPresent") 148 && e.getCause() instanceof NoSuchElementException) // issue #104: do not log error when waitForPresent raises TimeoutException149 || (e instanceof NotFoundException150 && isFromExpectedConditions(Thread.currentThread().getStackTrace())) // issue #194: return immediately if the action has been performed from ExpectedConditions class151 // This way, we let the FluentWait process to retry or re-raise the exception152 ) 153 {154 ignoreFailure = true; 155 throw e;156 }157 158 if (end.minusMillis(replay.replayDelayMs() + 100L).isAfter(systemClock.instant())) {159 WaitHelper.waitForMilliSeconds(replay.replayDelayMs());160 } else {161 if (e instanceof NoSuchElementException) {162 throw new NoSuchElementException(String.format("Searched element [%s] from page '%s' could not be found", element, element.getOrigin()));163 } else if (e instanceof UnreachableBrowserException) {164 throw new WebDriverException("Browser did not reply, it may have frozen");165 }166 throw e;167 }168 } 169 170 }171 return reply;172 } catch (Throwable e) {173 if (e instanceof NoSuchElementException 174 && joinPoint.getTarget() instanceof HtmlElement175 && (joinPoint.getSignature().getName().equals("findElements")176 || joinPoint.getSignature().getName().equals("findHtmlElements"))) {177 return new ArrayList<WebElement>();178 } else {179 if (!ignoreFailure) {180 actionFailed = true;181 currentException = e;182 }183 throw e;184 }185 } finally {186 if (currentAction != null && TestStepManager.getParentTestStep() != null) {187 currentAction.setFailed(actionFailed);188 scenarioLogger.logActionError(currentException);189 } 190 191 // restore element scrolling flag for further uses192 element.setScrollToElementBeforeAction(false);193 }194 }195 196 /**197 * Replay all actions annotated by ReplayOnError if the class is not a subclass of 198 * HtmlElement199 * @param joinPoint200 * @throws Throwable201 */202 @Around("!execution(public * com.seleniumtests.uipage.htmlelements.HtmlElement+.* (..))"203 + "&& execution(@com.seleniumtests.uipage.ReplayOnError public * * (..)) && @annotation(replay)")204 public Object replay(ProceedingJoinPoint joinPoint, ReplayOnError replay) throws Throwable {205 206 int replayDelayMs = replay != null ? replay.replayDelayMs(): 100;207 208 Instant end = systemClock.instant().plusSeconds(SeleniumTestsContextManager.getThreadContext().getReplayTimeout());209 Object reply = null;210 211 String targetName = joinPoint.getTarget().toString();212 TestAction currentAction = null;213214 if (joinPoint.getTarget() instanceof GenericPictureElement) {215 String methodName = joinPoint.getSignature().getName();216 List<String> pwdToReplace = new ArrayList<>();217 String actionName = String.format("%s on %s %s", methodName, targetName, LogAction.buildArgString(joinPoint, pwdToReplace, new HashMap<>()));218 currentAction = new TestAction(actionName, false, pwdToReplace);219 220 // log action before its started. By default, it's OK. Then result may be overwritten if step fails221 // order of steps is the right one (first called is first displayed)222 if (TestStepManager.getParentTestStep() != null) {223 TestStepManager.getParentTestStep().addAction(currentAction);224 }225 }226 227 boolean actionFailed = false;228 Throwable currentException = null;229 230 try {231 while (end.isAfter(systemClock.instant())) {232 233 // chrome automatically scrolls to element before interacting but it may scroll behind fixed header and no error is 234 // raised if action cannot be performed235 if (((CustomEventFiringWebDriver)WebUIDriver.getWebDriver(false)).getBrowserInfo().getBrowser() == BrowserType.CHROME236 || ((CustomEventFiringWebDriver)WebUIDriver.getWebDriver(false)).getBrowserInfo().getBrowser() == BrowserType.EDGE) {237 updateScrollFlagForElement(joinPoint, true, null);238 }239 240 try {241 reply = joinPoint.proceed(joinPoint.getArgs());242 WaitHelper.waitForMilliSeconds(200);243 break;244 245 // do not replay if error comes from scenario246 } catch (ScenarioException | ConfigurationException | DatasetException e) {247 throw e;248 } catch (MoveTargetOutOfBoundsException | InvalidElementStateException e) {249 updateScrollFlagForElement(joinPoint, null, e);250 } catch (Throwable e) {251 252 if (end.minusMillis(200).isAfter(systemClock.instant())) {253 WaitHelper.waitForMilliSeconds(replayDelayMs);254 continue;255 } else {256 throw e;257 }258 }259 }260 return reply;261 } catch (Throwable e) {262 actionFailed = true;263 currentException = e;264 throw e;265 } finally {266 if (currentAction != null && TestStepManager.getParentTestStep() != null) {267 currentAction.setFailed(actionFailed);268 scenarioLogger.logActionError(currentException);269 270 if (joinPoint.getTarget() instanceof GenericPictureElement) {271 currentAction.setDurationToExclude(((GenericPictureElement)joinPoint.getTarget()).getActionDuration());272 }273 } 274 }275 }276 277 /**278 * Replays the composite action in case any error occurs279 * @param joinPoint280 */281 @Around("execution(public void org.openqa.selenium.interactions.Actions.BuiltAction.perform ())")282 public Object replayCompositeAction(ProceedingJoinPoint joinPoint) throws Throwable {283 return replay(joinPoint, null);284 }285 286 /**287 * Updates the scrollToelementBeforeAction flag of HtmlElement for CompositeActions288 * Therefore, it looks at origin field of PointerInput$Move CompositeAction and update the flag289 * @throws SecurityException 290 * @throws NoSuchFieldException 291 * @throws IllegalAccessException 292 * @throws IllegalArgumentException 293 */294 private void updateScrollFlagForElement(ProceedingJoinPoint joinPoint, Boolean forcedValue, WebDriverException parentException) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {295 Object actions = joinPoint.getTarget();296 297 // the calling method 'replay(ProceedingJoinPoint joinPoint, ReplayOnError replay)' may be called from GenericPictureElement.class or from Selenium 'Composite Actions'298 // Only the later case is covered here299 if (!actions.getClass().toString().contains("BuiltAction")) {300 return;301 }302 303 Field sequencesField = actions.getClass().getDeclaredField("sequences");304 sequencesField.setAccessible(true);305 Map<InputSource, Sequence> sequences = (Map<InputSource, Sequence>) sequencesField.get(actions);306 307 for (Sequence sequence: sequences.values()) {308 Field actionsField = Sequence.class.getDeclaredField("actions");309 actionsField.setAccessible(true);310 311 LinkedList<Interaction> actionsList = (LinkedList<Interaction>)actionsField.get(sequence);312 313 for (Interaction action: actionsList) {314 if (action.getClass().getName().contains("PointerInput$Move")) {315 Field originField = action.getClass().getDeclaredField("origin");316 originField.setAccessible(true);317 try {318 PointerInput.Origin origin = (PointerInput.Origin) originField.get(action);319 320 // we can change 'scrollToelementBeforeAction' flag only for HtmlElement objects. For RemoteWebElement, this cannot be done so we rethrow the exception321 // so that it can be treated elsewhere (mainly inside replayHtmlElement())322 if (origin.asArg() instanceof HtmlElement) {323 HtmlElement element = (HtmlElement) origin.asArg();324 if (forcedValue == null) {325 if (element.isScrollToElementBeforeAction()) {326 element.setScrollToElementBeforeAction(false);327 } else {328 element.setScrollToElementBeforeAction(true); ...

Full Screen

Full Screen

Source:MouseTask.java Github

copy

Full Screen

...94 public String getDescription() {95 return this.description;96 }97 @Override98 public String getName() {99 return this.name;100 }101 /**102 * Set the name of the action103 *104 * @param name105 */106 public void setName(final String name) {107 this.name = name;108 }109 /**110 * The second element that is used in the dragAndDrop action111 *112 * @return...

Full Screen

Full Screen

Source:CompositeActions.java Github

copy

Full Screen

...123 Boolean clic = null;124 boolean clickRequested = false;125126 for (Interaction action: actionsList) {127 if (action.getClass().getName().contains("PointerInput$PointerPress")) {128 Field buttonField = action.getClass().getDeclaredField("button");129 buttonField.setAccessible(true);130 int button = buttonField.getInt(action);131 132 Field directionField = action.getClass().getDeclaredField("direction");133 directionField.setAccessible(true);134 String direction = directionField.get(action).toString();135 136 // only left button137 if (button != 0) {138 clic = null;139 continue;140 }141 ...

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");3PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");4PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");5PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");6PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");7PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");8PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");9PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");10PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");11PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");12PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");13PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");14PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");15PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");16PointerInput finger = new PointerInput(Pointer

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");3PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");4PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");5PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");6PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");7PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");8PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");9PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");10PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");11PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");12PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");13PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");14PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");15PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");16PointerInput finger = new PointerInput(Pointer

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2PointerInput.MouseButton button = finger.createButton(PointerInput.MouseButton.LEFT.asArg());3driver.perform(Arrays.asList(4 finger.createPointerMove(Duration.ZERO, Origin.viewport(), 0, 0),5 button.createPointerDown(PointerInput.MouseButton.LEFT.asArg()),6 button.createPointerUp(PointerInput.MouseButton.LEFT.asArg())7));8PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");9PointerInput.MouseButton button = finger.createButton(PointerInput.MouseButton.LEFT.asArg());10driver.perform(Arrays.asList(11 finger.createPointerMove(Duration.ZERO, Origin.viewport(), 0, 0),12 button.createPointerDown(PointerInput.MouseButton.LEFT.asArg()),13 button.createPointerUp(PointerInput.MouseButton.LEFT.asArg())14));15 (Session info: chrome=78.0.3904.70)16TouchActions action = new TouchActions(driver);17action.singleTap(element);18JavascriptExecutor js = (JavascriptExecutor) driver;19js.executeScript("window.scrollBy(0,500)");20element.click();21Actions actions = new Actions(driver);22actions.moveToElement(element).click().perform();

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2finger.getPointerId();3finger.getKind();4finger.getName();5finger.createPointerMove(Duration.ZERO, Origin.viewport(), 0, 0);6finger.createPointerDown(MouseButton.LEFT.asArg());7finger.createPointerUp(MouseButton.LEFT.asArg());

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 3OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));4action.setName("move finger");5action.perform(driver);6PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");7PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 8OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));9action.perform(driver);10PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");11PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 12OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));13action.perform(driver);14PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");15PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 16OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));17action.perform(driver);18PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");19PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 20OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));21action.perform(driver);22PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");23PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 24OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels(0, 0));25action.perform(driver);26PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");27PointerInput.MouseAction action = finger.createPointerMove(Duration.ofSeconds(0), 28OffsetInput.fromPixels(0, 0), OffsetInput.fromPixels

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, “finger”); 2TouchAction action = new TouchAction(driver); 3action.press(finger, 200, 200).perform(); 4action.moveTo(finger, 100, 100).perform(); 5action.release(finger).perform();6KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 7Keyboard keyboard = driver.getKeyboard(); 8keyboard.pressKey(key); 9keyboard.releaseKey(key);10KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 11Keyboard keyboard = driver.getKeyboard(); 12keyboard.pressKey(key); 13keyboard.releaseKey(key);14KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 15Keyboard keyboard = driver.getKeyboard(); 16keyboard.pressKey(key); 17keyboard.releaseKey(key);18KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 19Keyboard keyboard = driver.getKeyboard(); 20keyboard.pressKey(key); 21keyboard.releaseKey(key);22KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 23Keyboard keyboard = driver.getKeyboard(); 24keyboard.pressKey(key); 25keyboard.releaseKey(key);26KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 27Keyboard keyboard = driver.getKeyboard(); 28keyboard.pressKey(key); 29keyboard.releaseKey(key);30KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 31Keyboard keyboard = driver.getKeyboard(); 32keyboard.pressKey(key); 33keyboard.releaseKey(key);34KeyInput key = new KeyInput(KeyInput.Kind.KEYBOARD, “key”); 35Keyboard keyboard = driver.getKeyboard(); 36keyboard.pressKey(key); 37keyboard.releaseKey(key);

Full Screen

Full Screen

getName

Using AI Code Generation

copy

Full Screen

1PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");2PointerInput.MouseInput mouse = finger.createPointerMove(Duration.ZERO,3 Coordinates.of(0, 0), Coordinates.of(0, 0));4mouse.setName("mouse");5System.out.println(mouse.getName());6PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");7PointerInput.MouseInput mouse = finger.createPointerMove(Duration.ZERO,8 Coordinates.of(0, 0), Coordinates.of(0, 0));9mouse.setName("mouse");10System.out.println(mouse.getName());

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