@Override public Actions release(WebElement onElement) { super.release(onElement); return this; }
@Override public Actions release() { super.release(); return this; }
public void dragAndDropQuestionOption(String qnType, int qnNumber, int sourceIndex, int targetIndex) throws Exception { WebElement draggedOptionElement = browser.driver.findElement(By.xpath("//div[@id='" + qnType + "OptionRow-" + sourceIndex + "-" + qnNumber + "']//span[@class='glyphicon glyphicon-resize-vertical']")); WebElement targetElement = browser.driver.findElement(By.xpath("//div[@id='" + qnType + "OptionRow-" + targetIndex + "-" + qnNumber + "']//span[@class='glyphicon glyphicon-resize-vertical']")); Actions builder = new Actions(browser.driver); // drag option to target, move 10 units above target and release // multiple movements are used to slow down drag movement and provide // enough time for the grid to create empty slots builder.clickAndHold(draggedOptionElement) .moveToElement(targetElement) .moveToElement(targetElement, 0, -10) .release() .build() .perform(); }
WebElement elm = driver.findElement(By.id("btn1")); Actions builder = new Actions(driver); Action act = builder.clickAndHold(elm).build(); act.perform(); try { File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File("c:\\Img\\screenshot.png")); } catch (IOException e) { e.printStackTrace(); } act = builder.release(elm).build(); act.perform();
public Actions dragDropClickMoveRelease(Supplier<By> from, Supplier<By> to) { Actions build = new Actions(driver); build.clickAndHold(driver.findElement(from.get())).build().perform(); build.moveToElement(driver.findElement(to.get())).build().perform(); build.release(driver.findElement(to.get())).perform(); return build; }
@Override protected Void action(WebKey key, Object... param) throws ExecutionException { WebElement e = key == null ? null : fetcher.fetchElement(key); Actions actions = new Actions(driver); actions.release(e); actions.perform(); return null; } };
public void mouseDown(String locator) { LOG.keywordAppender().appendLocator(locator); WebElement el = finder.find(locator); if (el == null) { throw new IllegalStateException(String.format("ERROR: Element %s not found", locator)); } new Actions(driver).clickAndHold(el).release().perform(); }
public void mouseUp(String locator) { LOG.keywordAppender().appendLocator(locator); WebElement el = finder.find(locator); if (el == null) { throw new IllegalStateException(String.format("ERROR: Element %s not found", locator)); } new Actions(driver).clickAndHold(el).release().perform(); }
@Override public LazyDomElement dragAndDropTo(String destinationSelector) { return executeActions("dragAndDropTo(" + destinationSelector + ")", (element, actions) -> actions .clickAndHold(element) .pause(100) .release(driver().findElementByCssSelector(destinationSelector))); }
@JDIAction("Drag '{name}' and drop it to '{value}'") public void dragAndDropTo(UIElement to) { doActions(a -> a.clickAndHold(get()).moveToElement(to).release(to)); } @JDIAction("DoubleClick on '{name}'")
@Override public boolean run(TestRun ctx) { new Actions(ctx.driver()).release(ctx.locator("locator").find(ctx)).build().perform(); return true; } }
public void selectArea(int x1, int y1, int x2, int y2) { invoker.doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> { WebElement element = getWebElement(); new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold() .moveToElement(element, x2, y2).release().build().perform(); }); }
public void selectArea(int x1, int y1, int x2, int y2) { invoker.doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> { WebElement element = getWebElement(); new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold() .moveToElement(element, x2, y2).release().build().perform(); }); }
public void selectArea(int x1, int y1, int x2, int y2) { invoker.doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> { WebElement element = getWebElement(); new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold() .moveToElement(element, x2, y2).release().build().perform(); }); }
/** * Performs clicking and holding an {@code element} during specified {@code timeout}. * * @param element target element * @param holdingTimeout time for element holding */ public void clickAndHoldElementDuringTimeout(WebElement element, int holdingTimeout) { Actions action = getAction(); action.clickAndHold(waitVisibility(element)).perform(); WaitUtils.sleepQuietly(holdingTimeout); action.release(waitVisibility(element)).perform(); }
public void dragHandleToPointInTrace(int pixelInTrace) { Preconditions.checkArgument(pixelInTrace >= 0 && pixelInTrace <= getWidth(), "Cannot slide outside the trace."); if (!Utils.isVisible(advanced().getRootElement())) { throw new RuntimeException("Trace is not visible."); } scrollToView(); // clickAndHold(element) replaced by moveToElement with offset + clickAndHold (RF-14183) Actions actions = new Actions(browser).moveToElement(advanced().getHandleElement(), 0, 0).clickAndHold(); actions.moveToElement(advanced().getRootElement(), pixelInTrace, 0); actions.release(advanced().getHandleElement()).build().perform(); }
@Test public void testStalenessAndActionsOnWebElement1() { WebElement inStale = browser.findElement(By.className("stale")).findElement(By.className("in-stale")); Action action = new Actions(browser).clickAndHold(inStale).release(inStale).build(); makeStale.click(); action.perform(); }
public void moveCoverImage() { Actions actions = new Actions(driver); actions.clickAndHold(imageWindowDragging) .clickAndHold() .moveByOffset(-200, -200) .release() .perform(); }
public void reorderCategory(String categoryName, int offset) { final WebElement element = findEditableCategoryWith(categoryName); if (null != element) { WebElement dragElement = element.findElement(By.className(MOVE_COMMAND)); builder.moveToElement(element).clickAndHold(dragElement).perform(); // The first move doesn't work properly so do a no-op builder.moveByOffset(0, 0).moveByOffset(0, offset * CATEGORY_INPUT_HEIGHT_PX).perform(); wait.forX(Duration.ofMillis(100)); builder.release().perform(); } } }
public void select_upto(Element other_element) { Actions actions = new Actions(browser.driver()); actions.moveToElement(_nativeWebElement()).build().perform(); wait_between_steps_plus(1); actions.clickAndHold(_nativeWebElement()).build().perform(); wait_between_steps_plus(1); actions.moveToElement(other_element._nativeWebElement()).build().perform(); wait_between_steps_plus(1); actions.release().build().perform(); }