org.openqa.selenium.interactions.Coordinates Java Examples
The following examples show how to use
org.openqa.selenium.interactions.Coordinates.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MouseMoveToLocation.java From selenium with Apache License 2.0 | 6 votes |
@Override public Void call() { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); Coordinates elementLocation = null; if (elementProvided) { WebElement element = getKnownElements().get(elementId); elementLocation = ((Locatable) element).getCoordinates(); } if (offsetsProvided) { mouse.mouseMove(elementLocation, xOffset, yOffset); } else { mouse.mouseMove(elementLocation); } return null; }
Example #2
Source File: DefaultFieldDecoratorTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void testDecoratingProxyImplementsRequiredInterfaces() { final AllDriver driver = mock(AllDriver.class); final AllElement element = mock(AllElement.class); final Mouse mouse = mock(Mouse.class); when(driver.getMouse()).thenReturn(mouse); when(element.getCoordinates()).thenReturn(mock(Coordinates.class)); when(driver.findElement(By.id("foo"))).thenReturn(element); Page page = new Page(); PageFactory.initElements(driver, page); new Actions(driver).moveToElement(page.foo).build().perform(); verify(driver).getKeyboard(); verify(driver).getMouse(); verify(element).getCoordinates(); verify(mouse).mouseMove(any(Coordinates.class)); }
Example #3
Source File: DelegatingWebElementTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testGetCoordinates() { WebElement locatableWebElement = Mockito.mock(WebElement.class, withSettings().extraInterfaces(Locatable.class)); Coordinates coordinates = Mockito.mock(Coordinates.class); when(((Locatable) locatableWebElement).getCoordinates()).thenReturn(coordinates); DelegatingWebElement locatableDelegatingWebElement = new DelegatingWebElement(locatableWebElement); assertEquals(coordinates, locatableDelegatingWebElement.getCoordinates()); }
Example #4
Source File: Scroll.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch(); if (elementId != null) { WebElement element = getKnownElements().get(elementId); Coordinates elementLocation = ((Locatable) element).getCoordinates(); touchScreen.scroll(elementLocation, xOffset, yOffset); } else { touchScreen.scroll(xOffset, yOffset); } return null; }
Example #5
Source File: LongPressOnElement.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch(); WebElement element = getKnownElements().get(elementId); Coordinates elementLocation = ((Locatable) element).getCoordinates(); touchScreen.longPress(elementLocation); return null; }
Example #6
Source File: DoubleTapOnElement.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch(); WebElement element = getKnownElements().get(elementId); Coordinates elementLocation = ((Locatable) element).getCoordinates(); touchScreen.doubleTap(elementLocation); return null; }
Example #7
Source File: Flick.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch(); if (elementId != null) { WebElement element = getKnownElements().get(elementId); Coordinates elementLocation = ((Locatable) element).getCoordinates(); touchScreen.flick(elementLocation, xOffset, yOffset, speed); } else { touchScreen.flick(xSpeed, ySpeed); } return null; }
Example #8
Source File: SingleTapOnElement.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { TouchScreen touchScreen = ((HasTouchScreen) getDriver()).getTouch(); WebElement element = getKnownElements().get(elementId); Coordinates elementLocation = ((Locatable) element).getCoordinates(); touchScreen.singleTap(elementLocation); return null; }
Example #9
Source File: RemoteWebElement.java From selenium with Apache License 2.0 | 5 votes |
@Override public Coordinates getCoordinates() { return new Coordinates() { @Override public Point onScreen() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Point inViewPort() { Response response = execute(DriverCommand.GET_ELEMENT_LOCATION_ONCE_SCROLLED_INTO_VIEW(getId())); @SuppressWarnings("unchecked") Map<String, Number> mapped = (Map<String, Number>) response.getValue(); return new Point(mapped.get("x") .intValue(), mapped.get("y") .intValue()); } @Override public Point onPage() { return getLocation(); } @Override public Object getAuxiliary() { return getId(); } }; }
Example #10
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 5 votes |
@Override public void mouseMove(Coordinates where, long xOffset, long yOffset) { Map<String, Object> moveParams = paramsFromCoordinates(where); moveParams.put("xoffset", xOffset); moveParams.put("yoffset", yOffset); executor.execute(DriverCommand.MOVE_TO, moveParams); }
Example #11
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 5 votes |
protected Map<String, Object> paramsFromCoordinates(Coordinates where) { Map<String, Object> params = new HashMap<>(); if (where != null) { String id = (String) where.getAuxiliary(); params.put("element", id); } return params; }
Example #12
Source File: RemoteTouchScreen.java From selenium with Apache License 2.0 | 5 votes |
private static Map<String, Object> paramsFromCoordinates(Coordinates where) { Map<String, Object> params = new HashMap<>(); if (where != null) { String id = (String) where.getAuxiliary(); params.put("element", id); } return params; }
Example #13
Source File: RemoteTouchScreen.java From selenium with Apache License 2.0 | 5 votes |
@Override public void flick(Coordinates where, int xOffset, int yOffset, int speed) { Map<String, Object> flickParams = paramsFromCoordinates(where); flickParams.put("xoffset", xOffset); flickParams.put("yoffset", yOffset); flickParams.put("speed", speed); executeMethod.execute(DriverCommand.TOUCH_FLICK, flickParams); }
Example #14
Source File: RemoteTouchScreen.java From selenium with Apache License 2.0 | 5 votes |
@Override public void scroll(Coordinates where, int xOffset, int yOffset) { Map<String, Object> scrollParams = paramsFromCoordinates(where); scrollParams.put("xoffset", xOffset); scrollParams.put("yoffset", yOffset); executeMethod.execute(DriverCommand.TOUCH_SCROLL, scrollParams); }
Example #15
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void clickInvisibleElement() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); Coordinates coordinates = mock(Coordinates.class); when(((Locatable) locatableWebElement).getCoordinates()).thenReturn(coordinates); mouseActions.moveToAndClick(locatableWebElement); verify(mouse).mouseMove(coordinates); verify(mouse).click(null); }
Example #16
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testContextClick() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); Coordinates coordinates = mock(Coordinates.class); when(((Locatable) locatableWebElement).getCoordinates()).thenReturn(coordinates); mouseActions.contextClick(locatableWebElement); verify(mouse).contextClick(coordinates); }
Example #17
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testMoveToElement() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); Coordinates coordinates = mock(Coordinates.class); when(((Locatable) locatableWebElement).getCoordinates()).thenReturn(coordinates); mouseActions.moveToElement(locatableWebElement); verify(mouse).mouseMove(coordinates); }
Example #18
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testMoveToElementMoveTargetOutOfBoundsException() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); MoveTargetOutOfBoundsException boundsException = new MoveTargetOutOfBoundsException( COULD_NOT_MOVE_TO_ERROR_MESSAGE); Coordinates coordinates = mock(Coordinates.class); when(((Locatable) locatableWebElement).getCoordinates()).thenReturn(coordinates); doThrow(boundsException).when(mouse).mouseMove(coordinates); mouseActions.moveToElement(locatableWebElement); verify(softAssert).recordFailedAssertion(COULD_NOT_MOVE_TO_ERROR_MESSAGE + boundsException); }
Example #19
Source File: MouseAction.java From selenium with Apache License 2.0 | 5 votes |
protected Coordinates getActionLocation() { if (where == null) { return null; } return where.getCoordinates(); }
Example #20
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
protected void moveIfNeeded(Coordinates where) { if (where != null) { mouseMove(where); } }
Example #21
Source File: DelegatingWebElement.java From vividus with Apache License 2.0 | 4 votes |
@Override public Coordinates getCoordinates() { return ((Locatable) wrappedElement).getCoordinates(); }
Example #22
Source File: BaseTeasyElement.java From teasy with MIT License | 4 votes |
@Override public Coordinates getCoordinates() { return ((org.openqa.selenium.interactions.Locatable) getWrappedWebElement()).getCoordinates(); }
Example #23
Source File: BobcatWebElement.java From bobcat with Apache License 2.0 | 4 votes |
@Override public Coordinates getCoordinates() { return locatable.getCoordinates(); }
Example #24
Source File: DisplayAction.java From selenium with Apache License 2.0 | 4 votes |
protected Coordinates getActionLocation() { return (where == null) ? null : where.getCoordinates(); }
Example #25
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void mouseMove(Coordinates where) { Map<String, Object> moveParams = paramsFromCoordinates(where); executor.execute(DriverCommand.MOVE_TO, moveParams); }
Example #26
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void mouseUp(Coordinates where) { moveIfNeeded(where); executor.execute(DriverCommand.MOUSE_UP, ImmutableMap.of()); }
Example #27
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void mouseDown(Coordinates where) { moveIfNeeded(where); executor.execute(DriverCommand.MOUSE_DOWN, ImmutableMap.of()); }
Example #28
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void doubleClick(Coordinates where) { moveIfNeeded(where); executor.execute(DriverCommand.DOUBLE_CLICK, ImmutableMap.of()); }
Example #29
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void contextClick(Coordinates where) { moveIfNeeded(where); executor.execute(DriverCommand.CLICK, ImmutableMap.of("button", 2)); }
Example #30
Source File: RemoteMouse.java From selenium with Apache License 2.0 | 4 votes |
@Override public void click(Coordinates where) { moveIfNeeded(where); executor.execute(DriverCommand.CLICK, ImmutableMap.of("button", 0)); }