@Override public Void call() throws Exception { 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; }
@Step public EndUserSteps dragsCardToOtherLocation(Card card, TableLocation fromLocation, TableLocation toLocation) { TablePage page = getTablePage(); Optional<WebElementFacade> maybeCard = page.getCardAtTableLocationElement(card, fromLocation); assertTrue(maybeCard.isPresent()); Optional<WebElementFacade> maybeTableLocation = page.getTableLocationElement(toLocation); assertTrue(maybeTableLocation.isPresent()); Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseMove(maybeCard.get().getCoordinates(), 3, 3); // grab the top left corner mouse.mouseDown(null); // at the current location mouse.mouseMove(maybeTableLocation.get().getCoordinates()); mouse.mouseUp(maybeTableLocation.get().getCoordinates()); return this; }
@Override public Keyboard getKeyboard() { setLastAction(); if ( webDriver instanceof HasInputDevices ) return ((HasInputDevices) webDriver).getKeyboard(); else return null; }
@Override public Mouse getMouse() { setLastAction(); if ( webDriver instanceof HasInputDevices ) return ((HasInputDevices) webDriver).getMouse(); else return null; }
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( 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; }
public boolean _clickFor( int length ) { 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( webElement ).waitAction( Duration.ofMillis( length ) ).release().perform(); } else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver ) { double x = webElement.getLocation().getX() + (webElement.getSize().getWidth() / 2); double y = webElement.getLocation().getY() + (webElement.getSize().getHeight() / 2); int percentX = (int) ( x / getWebDriver().manage().window().getSize().getWidth() * 100.0 ); int percentY = (int) ( y / getWebDriver().manage().window().getSize().getHeight() * 100.0 ); try { new TouchActions( getWebDriver() ).longPress( webElement ).build().perform(); } catch ( Exception e ) { ((DeviceWebDriver) getWebDriver()).getCloud().getCloudActionProvider().tap( (DeviceWebDriver) getWebDriver(), new PercentagePoint( percentX, percentY, true ), length ); } } return true; } } return false; }
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( 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; }
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 TouchAction( (AppiumDriver) ((DeviceWebDriver) getWebDriver()).getNativeDriver() ).tap( webElement ).tap( 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; }
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; }
/** * 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); }
/** * 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()); }
/** * 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); }
@Override public Void call() throws Exception { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); if (leftMouseButton) { mouse.click(null); } else { mouse.contextClick(null); } return null; }
@Override public Void call() throws Exception { Keyboard keyboard = ((HasInputDevices) getDriver()).getKeyboard(); String[] keysToSend = keys.toArray(new String[0]); keyboard.sendKeys(keysToSend); return null; }
@Override public Keyboard getKeyboard() { return ((HasInputDevices) driver).getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices) driver).getMouse(); }
public boolean _clickAt( int offsetX, int offsetY ) { WebElement webElement = getElement(); if ( webElement != null ) { Dimension elementSize = webElement.getSize(); int useX = (int) ((double) elementSize.getWidth() * ((double) offsetX / 100.0)); int useY = (int) ((double) elementSize.getHeight() * ((double) offsetY / 100.0)); if ( log.isInfoEnabled() ) log.info( "Clicking " + useX + "," + useY + " pixels relative to " + getName() ); 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( webElement ).tap( webElement, useX, useY ).perform(); } else if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof RemoteWebDriver ) { if ( ((DeviceWebDriver) getWebDriver()).getNativeDriver() instanceof HasTouchScreen ) new TouchActions( getWebDriver() ).moveToElement( webElement, useX, useY ).click().build().perform(); else new Actions( getWebDriver() ).moveToElement( webElement, useX, useY ).click().build().perform(); } return true; } return true; } return false; }
private HasInputDevices inputDevices() { if (!(driver instanceof HasInputDevices)) { throw new UnsupportedOperationException("Driver has no input device"); } return (HasInputDevices) driver; }
/** * @return the {@link Keyboard} of current driver */ public Keyboard getKeyboard() { return ((HasInputDevices) seleniumWebDriver()).getKeyboard(); }
/** * @return the {@link Mouse} of current driver */ public Mouse getMouse() { return ((HasInputDevices) seleniumWebDriver()).getMouse(); }
@Override public Keyboard getKeyboard() { return ((HasInputDevices)driver).getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices)driver).getMouse(); }
@BeforeMethod public void setUp() throws Exception { webDriver = Mockito.mock( WebDriver.class, Mockito.withSettings().extraInterfaces(HasInputDevices.class)); }
@Override public Void call() throws Exception { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseDown(null); return null; }
@Override public Void call() throws Exception { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.doubleClick(null); return null; }
@Override public Void call() throws Exception { Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseUp(null); return null; }
/** * * @return */ @Override public Keyboard getKeyboard() { return ((HasInputDevices) driver).getKeyboard(); }
/** * * @return */ @Override public Mouse getMouse() { return ((HasInputDevices) driver).getMouse(); }
@Override public void perform(final WebElement target) { final Locatable hoverItem = (Locatable) target; final Mouse mouse = ((HasInputDevices) webDriver).getMouse(); mouse.mouseMove(hoverItem.getCoordinates()); }
@Override default Keyboard getKeyboard() { HasInputDevices t = (HasInputDevices) get(); return t.getKeyboard(); }
@Override default Mouse getMouse() { HasInputDevices t = (HasInputDevices) get(); return t.getMouse(); }
@Override public Keyboard getKeyboard() { return ((HasInputDevices) webDriver).getKeyboard(); }
@Override public Mouse getMouse() { return ((HasInputDevices) webDriver).getMouse(); }
protected Mouse delegateMouse() { return ((HasInputDevices) delegate).getMouse(); }
protected Keyboard delegateKeyboard() { return ((HasInputDevices) delegate).getKeyboard(); }