List of usage examples for org.openqa.selenium.interactions Actions moveByOffset
public Actions moveByOffset(int xOffset, int yOffset)
From source file:com.cognifide.qa.bb.dragdrop.DraggableWebElement.java
License:Apache License
private void performMovement(int movement, Orientantion orientantion, Actions builder) { int movementRemains = Math.abs(movement); int movementDirection = Integer.signum(movement); while (movementRemains > 0) { int movementStep = movementRemains >= MOVEMENT_STEP ? MOVEMENT_STEP : 1; if (orientantion.equals(Orientantion.VERTICAL)) { builder.moveByOffset(0, movementDirection * movementStep); } else {/*from w w w.ja v a2s . c o m*/ builder.moveByOffset(movementDirection * movementStep, 0); } movementRemains -= movementStep; } }
From source file:com.ecofactor.qa.automation.platform.action.impl.DesktopUIAction.java
License:Open Source License
/** * Drag element.//from w w w.java2 s. co m * @param srcElement the src element * @param xOffset the x offset * @param yOffset the y offset * @see com.ecofactor.qa.automation.platform.action.UIAction#dragElement(org.openqa.selenium.WebElement, * org.openqa.selenium.WebElement) */ @Override public void dragElement(final WebElement srcElement, final Integer xOffset, final Integer yOffset) { setLogString("Drag element..", true, CustomLogLevel.HIGH); final Actions builder = new Actions(driverOps.getDeviceDriver()); oneSec(); builder.clickAndHold(srcElement).build().perform(); oneSec(); builder.moveByOffset(xOffset, yOffset).build().perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void mouseOut(String locator) { WebElement webElement = getWebElement(locator); scrollWebElementIntoView(webElement); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); actions.moveToElement(webElement);/* ww w . j a v a2 s.co m*/ actions.moveByOffset(10, 10); Action action = actions.build(); action.perform(); }
From source file:com.screenslicer.core.scrape.QueryKeyword.java
License:Open Source License
private static void hoverClick(RemoteWebDriver driver, WebElement element) throws ActionFailed { try {//w w w . ja v a2 s . c o m String oldHandle = driver.getWindowHandle(); Actions action = new Actions(driver); Util.click(driver, element); action.moveByOffset(-MOUSE_MOVE_OFFSET, -MOUSE_MOVE_OFFSET).perform(); action.moveToElement(element).perform(); action.moveByOffset(2, 2).perform(); Util.driverSleepShort(); Util.cleanUpNewWindows(driver, oldHandle); } catch (Throwable t) { Log.exception(t); throw new ActionFailed(t); } }
From source file:com.vaadin.testbench.elements.WindowElement.java
License:Apache License
/** * Moves the window by given offset./*from w w w .j av a 2 s . c o m*/ * * @param xOffset * x offset * @param yOffset * y offset */ public void move(int xOffset, int yOffset) { Actions action = new Actions(getDriver()); action.moveToElement(findElement(org.openqa.selenium.By.className("v-window-wrap")), 5, 5); action.clickAndHold(); action.moveByOffset(xOffset, yOffset); action.release(); action.build().perform(); }
From source file:com.vaadin.tests.components.calendar.CalendarResizeOverlappingEventsTest.java
License:Apache License
private void dragAndDrop(WebElement element, int yOffset) { /*/*from www .ja v a 2s . co m*/ * Selenium doesn't properly drag and drop items in IE8. It tries to * start dragging an element from a position above the element itself. */ if (BrowserUtil.isIE8(getDesiredCapabilities())) { Actions action = new Actions(getDriver()); action.moveToElement(element); action.moveByOffset(0, 1); action.clickAndHold(); action.moveByOffset(0, yOffset); action.release(); action.build().perform(); } else { Actions action = new Actions(getDriver()); action.dragAndDropBy(element, 0, yOffset); action.build().perform(); } }
From source file:de.learnlib.alex.data.entities.actions.web.MoveMouseAction.java
License:Apache License
@Override protected ExecuteResult execute(WebSiteConnector connector) { final WebElementLocator nodeWithVariables = node == null ? null : new WebElementLocator(insertVariableValues(node.getSelector()), node.getType()); try {/*from w w w .j a va 2 s . c o m*/ final Actions actions = new Actions(connector.getDriver()); if (nodeWithVariables == null || nodeWithVariables.getSelector().trim().equals("")) { actions.moveByOffset(offsetX, offsetY).build().perform(); LOGGER.info(LoggerMarkers.LEARNER, "Moved the mouse to the position ({}, {}) ", offsetX, offsetY); } else { final WebElement element = connector.getElement(nodeWithVariables); actions.moveToElement(element, offsetX, offsetY).build().perform(); LOGGER.info(LoggerMarkers.LEARNER, "Moved the mouse to the element '{}'", nodeWithVariables); } return getSuccessOutput(); } catch (Exception e) { LOGGER.info(LoggerMarkers.LEARNER, "Could not move the mouse to the element '{}' or the position ({}, {})", nodeWithVariables, offsetX, offsetY); return getFailedOutput(); } }
From source file:org.evilco.bot.powersweeper.game.ScreenGameInterface.java
License:Apache License
/** * {@inheritDoc}// w w w. j a va 2 s. com */ @Override public void moveToChunk(@NonNull ChunkLocation location) { getLogger().entry(); // check whether sane movement is possible if (this.chunkLocation != null) { // calculate distance ChunkLocation distance = this.chunkLocation.getDistance(location); ChunkLocation distanceSanitized = new ChunkLocation(distance); distanceSanitized.sanitize(); // verify whether sane movement is possible if (distanceSanitized.getX() <= SANE_MOVEMENT_THRESHOLD && distanceSanitized.getY() <= SANE_MOVEMENT_THRESHOLD) { // calculate distance long x = ((this.chunk.getWidth() * CELL_SIZE) * distance.getX()); long y = ((this.chunk.getHeight() * CELL_SIZE) * distance.getY()); // verify if (x > Integer.MAX_VALUE || y > Integer.MAX_VALUE) getLogger().warn("Sane movement threshold of " + SANE_MOVEMENT_THRESHOLD + " seems to be too big. Aborting."); else { // find HTML WebElement html = this.getPowersweeper().getDriverManager().getDriver() .findElement(By.tagName("html")); // build action Actions action = new Actions(this.getPowersweeper().getDriverManager().getDriver()); action.moveToElement(html, (CELL_SIZE / 2), (CELL_SIZE / 2)); action.clickAndHold(); action.moveByOffset(((int) x), ((int) y)); action.release(); // execute action.build().perform(); // wait for a few seconds try { Thread.sleep(2000); } catch (Exception ex) { getLogger().warn("Aliens wake us up to early."); } // update location this.chunkLocation = location; // force update this.update(); // trace getLogger().exit(); // skip return; } } } // open new URL this.getPowersweeper().getDriverManager().getDriver() .get(String.format(GAME_URL, location.getX(), location.getY())); // wait for a few seconds try { Thread.sleep(5000); } catch (Exception ex) { getLogger().warn("Aliens wake us up to early."); } // update location this.chunkLocation = location; // force update this.update(); // trace getLogger().exit(); }
From source file:org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils.java
License:Open Source License
public void moveResourceInstanceToCanvasUI() throws Exception { List<WebElement> moveResource = driver.findElements(By.className("sprite-resource-icons")); WebElement moveResourceToCanvasResourceOne = moveResource.get(0); // WebElement moveResource = // driver.findElement(By.className("sprite-resource-icons")); Actions action = new Actions(driver); action.moveToElement(moveResourceToCanvasResourceOne); action.clickAndHold(moveResourceToCanvasResourceOne); action.moveByOffset(635, 375); action.release();/*from ww w . j a v a 2 s . c o m*/ action.perform(); WebElement moveResourceToCanvasResourceTwo = moveResource.get(1); action.moveToElement(moveResourceToCanvasResourceTwo); action.clickAndHold(moveResourceToCanvasResourceTwo); action.moveByOffset(535, 375); action.release(); action.perform(); WebElement moveResourceToCanvasResourceTree = moveResource.get(2); action.moveToElement(moveResourceToCanvasResourceTree); action.clickAndHold(moveResourceToCanvasResourceTree); action.moveByOffset(435, 375); action.release(); action.perform(); Thread.sleep(2000); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testRendered() throws InterruptedException { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(rendered, true); // before any mouse move, no indicator appears on page elementNotPresent.element(page.indicator).apply(driver); Actions actionQueue = new Actions(driver); // firstly just drag and don't move. Indicator no displayed Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();//from ww w . j a v a 2s . c o m elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); // simulate drop dragging = actionQueue.release().build(); elementPresent.element(page.indicator); dragging.perform(); elementNotPresent.element(page.indicator).apply(driver); // and now the same with indicator not rendered dragIndicatorAttributes.set(rendered, false); elementNotPresent.element(page.indicator).apply(driver); // just small move to attempt display indicator dragging = actionQueue.clickAndHold(page.drag1).moveByOffset(1, 1).build(); dragging.perform(); elementNotPresent.element(page.indicator); }