org.openqa.selenium.interactions.HasInputDevices Java Examples
The following examples show how to use
org.openqa.selenium.interactions.HasInputDevices.
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: DelegatingWebDriver.java From vividus with Apache License 2.0 | 5 votes |
@Override public Mouse getMouse() { if (wrappedDriver instanceof HasInputDevices) { return ((HasInputDevices) wrappedDriver).getMouse(); } throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED); }
Example #3
Source File: SendKeyToActiveElement.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { Keyboard keyboard = ((HasInputDevices) getDriver()).getKeyboard(); String[] keysToSend = keys.toArray(new String[0]); keyboard.sendKeys(keysToSend); return null; }
Example #4
Source File: ClickInSession.java From selenium with Apache License 2.0 | 5 votes |
@Override public Void call() { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); if (leftMouseButton) { mouse.click(null); } else { mouse.contextClick(null); } return null; }
Example #5
Source File: EventFiringWebDriver.java From selenium with Apache License 2.0 | 5 votes |
@Override public Mouse getMouse() { if (driver instanceof HasInputDevices) { return new EventFiringMouse(driver, dispatcher); } throw new UnsupportedOperationException("Underlying driver does not implement advanced" + " user interactions yet."); }
Example #6
Source File: EventFiringWebDriver.java From selenium with Apache License 2.0 | 5 votes |
@Override public Keyboard getKeyboard() { if (driver instanceof HasInputDevices) { return new EventFiringKeyboard(driver, dispatcher); } throw new UnsupportedOperationException("Underlying driver does not implement advanced" + " user interactions yet."); }
Example #7
Source File: HtmlElement.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
/** * Forces a mouseUp event on the WebElement. */ public void mouseUp() { TestLogging.log("MouseUp " + this.toString()); findElement(); final Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseUp(null); }
Example #8
Source File: HtmlElement.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
/** * Forces a mouseOver event on the WebElement. */ public void mouseOver() { TestLogging.log("MouseOver " + this.toString()); findElement(); // build and perform the mouseOver with Advanced User Interactions API // Actions builder = new Actions(driver); // builder.moveToElement(element).build().perform(); final Locatable hoverItem = (Locatable) element; final Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseMove(hoverItem.getCoordinates()); }
Example #9
Source File: HtmlElement.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
/** * Forces a mouseDown event on the WebElement. */ public void mouseDown() { TestLogging.log("MouseDown " + this.toString()); findElement(); final Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseDown(null); }
Example #10
Source File: SeleniumElement.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public boolean _release() { WebElement webElement = getElement(); if (webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0) { if (getWebDriver() instanceof HasInputDevices) { if (isTimed()) getActionProvider().startTimer((DeviceWebDriver) getWebDriver(), this, getExecutionContext()); if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver) { new TouchAction((AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver()).release().perform(); } else if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver) { if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen) new TouchActions(getWebDriver()).release().build().perform(); else new Actions(getWebDriver()).release().build().perform(); } return true; } } return false; }
Example #11
Source File: SeleniumElement.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public boolean _mouseDoubleClick() { WebElement webElement = getElement(); if (webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0) { if (getWebDriver() instanceof HasInputDevices) { if (isTimed()) getActionProvider().startTimer((DeviceWebDriver) getWebDriver(), this, getExecutionContext()); if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver) { new TouchActions((AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver()).doubleTap(webElement).perform(); } else if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver) { if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen) new TouchActions(getWebDriver()).doubleClick().build().perform(); else new Actions(getWebDriver()).doubleClick(webElement).build().perform(); } return true; } } return false; }
Example #12
Source File: SeleniumElement.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public boolean _clickAt( int offsetX, int offsetY ) { WebElement webElement = getElement(); if (webElement != null) { CloudActionProvider aP = getWebDriver().getCloud().getCloudActionProvider(); Dimension elementSize = aP.translateDimension(getWebDriver(), webElement.getSize()); int useX = (int) ((double) elementSize.getWidth() * ((double) offsetX / 100.0) + webElement.getLocation().getX()); int useY = (int) ((double) elementSize.getHeight() * ((double) offsetY / 100.0) + webElement.getLocation().getY()); if (log.isInfoEnabled()) log.info("Clicking " + useX + "," + useY + " pixels relative to " + getName()); if (getWebDriver() instanceof HasInputDevices) { if (isTimed()) getActionProvider().startTimer((DeviceWebDriver) getWebDriver(), this, getExecutionContext()); aP.tap(getWebDriver(), new PercentagePoint(useX, useY, false), 500); return true; } return true; } return false; }
Example #13
Source File: SeleniumElement.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public boolean _press() { WebElement webElement = getElement(); if (webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0) { if (getWebDriver() instanceof HasInputDevices) { if (isTimed()) getActionProvider().startTimer((DeviceWebDriver) getWebDriver(), this, getExecutionContext()); if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver) { new TouchAction((AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver()).press(createPoint(webElement)).perform(); } else if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver) { if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen) new TouchActions(getWebDriver()).clickAndHold(webElement).build().perform(); else new Actions(getWebDriver()).clickAndHold(webElement).build().perform(); } return true; } } return false; }
Example #14
Source File: SeleniumElement.java From xframium-java with GNU General Public License v3.0 | 5 votes |
public boolean _moveTo() { WebElement webElement = getElement(); if (webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0) { if (getWebDriver() instanceof HasInputDevices) { if (isTimed()) getActionProvider().startTimer((DeviceWebDriver) getWebDriver(), this, getExecutionContext()); if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof AppiumDriver) { new TouchAction((AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver()).moveTo(createPoint(webElement)).perform(); } else if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver) { if (((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen) new TouchActions(getWebDriver()).moveToElement(webElement).build().perform(); else new Actions(getWebDriver()).moveToElement(webElement).build().perform(); } return true; } } return false; }
Example #15
Source File: DeviceWebDriver.java From xframium-java with GNU General Public License v3.0 | 5 votes |
@Override public Keyboard getKeyboard() { setLastAction(); if ( webDriver instanceof HasInputDevices ) return ((HasInputDevices) webDriver).getKeyboard(); else return null; }
Example #16
Source File: DeviceWebDriver.java From xframium-java with GNU General Public License v3.0 | 5 votes |
@Override public Mouse getMouse() { setLastAction(); if ( webDriver instanceof HasInputDevices ) return ((HasInputDevices) webDriver).getMouse(); else return null; }
Example #17
Source File: DelegatingWebDriver.java From vividus with Apache License 2.0 | 5 votes |
@Override public Keyboard getKeyboard() { if (wrappedDriver instanceof HasInputDevices) { return ((HasInputDevices) wrappedDriver).getKeyboard(); } throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED); }
Example #18
Source File: ProxyFactory.java From healenium-web with Apache License 2.0 | 5 votes |
public static <T extends WebDriver> SelfHealingDriver createDriverProxy(ClassLoader loader, InvocationHandler handler, Class<T> clazz) { Class<?>[] interfaces = Stream.concat( Arrays.stream(clazz.getInterfaces()), Stream.of(JavascriptExecutor.class, SelfHealingDriver.class, HasInputDevices.class, Interactive.class) ).distinct().toArray(Class[]::new); return (SelfHealingDriver) Proxy.newProxyInstance(loader, interfaces, handler); }
Example #19
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void shouldScrollToElementOnBrowsersNotPerformingScrollAutomatically() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); when(webDriverManager.isMobile()).thenReturn(false); when(webDriverManager.isTypeAnyOf(WebDriverType.SAFARI, WebDriverType.FIREFOX, WebDriverType.EDGE)) .thenReturn(true); mouseActions.moveToElement(locatableWebElement); verify(javascriptActions).scrollIntoView(locatableWebElement, true); }
Example #20
Source File: DelegatingWebDriverTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testGetKeyboard() { WebDriver driverWithInputDevices = Mockito.mock(WebDriver.class, withSettings().extraInterfaces(HasInputDevices.class)); Keyboard keyboard = Mockito.mock(Keyboard.class); when(((HasInputDevices) driverWithInputDevices).getKeyboard()).thenReturn(keyboard); assertEquals(keyboard, new DelegatingWebDriver(driverWithInputDevices).getKeyboard()); }
Example #21
Source File: MouseActionsTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testMoveToElementOnMobile() { when(webDriverProvider.get()).thenReturn(webDriver); when(((HasInputDevices) webDriver).getMouse()).thenReturn(mouse); when(webDriverManager.isMobile()).thenReturn(true); mouseActions.moveToElement(locatableWebElement); verify(javascriptActions).scrollIntoView(locatableWebElement, true); }
Example #22
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 #23
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 #24
Source File: DelegatingWebDriverTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testGetMouse() { WebDriver driverWithInputDevices = Mockito.mock(WebDriver.class, withSettings().extraInterfaces(HasInputDevices.class)); Mouse mouse = Mockito.mock(Mouse.class); when(((HasInputDevices) driverWithInputDevices).getMouse()).thenReturn(mouse); assertEquals(mouse, new DelegatingWebDriver(driverWithInputDevices).getMouse()); }
Example #25
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 #26
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 #27
Source File: MouseUp.java From selenium with Apache License 2.0 | 4 votes |
@Override public Void call() { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseUp(null); return null; }
Example #28
Source File: DoubleClickInSession.java From selenium with Apache License 2.0 | 4 votes |
@Override public Void call() { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.doubleClick(null); return null; }
Example #29
Source File: MouseDown.java From selenium with Apache License 2.0 | 4 votes |
@Override public Void call() { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseDown(null); return null; }
Example #30
Source File: EventFiringMouse.java From selenium with Apache License 2.0 | 4 votes |
public EventFiringMouse(WebDriver driver, WebDriverEventListener dispatcher) { this.driver = driver; this.dispatcher = dispatcher; this.mouse = ((HasInputDevices) this.driver).getMouse(); }