@Override public Actions dragAndDropBy(WebElement source, int xOffset, int yOffset) { super.dragAndDropBy(source, xOffset, yOffset); return this; }
public ObjectPage filter(int lowerThreshold, int highThreshold) { Actions action = new Actions(getWebDriver()); action.dragAndDropBy(findElement(".className .thumbMin"), lowerThreshold, 0).perform(); waitFor(elementIsNotDisplayed("#waiting_dialog")); action.dragAndDropBy(findElement(".className .thumbMax"), highThreshold, 0).perform(); waitFor(elementIsNotDisplayed("#waiting_dialog")); return this; }
public ObjectPage filter(int lowerThreshold, int highThreshold) { Actions action = new Actions(getWebDriver()); action.dragAndDropBy(findElement(".className .thumbMin"), lowerThreshold, 0).perform(); waitFor(elementIsNotDisplayed("#waiting_dialog")); action.dragAndDropBy(findElement(".className .thumbMax"), highThreshold, 0).perform(); waitFor(elementIsNotDisplayed("#waiting_dialog")); return this; }
driver.get("http://talkerscode.com/webtricks/demo/demo_price-range-slider-using-jquery-css-and-php.php"); Actions act = new Actions(driver); WebElement pricebar = driver.findElement(By.xpath("//div[@id='slider-range']//span[2]")); act.dragAndDropBy(pricebar, 100, 0).build().perform();
WebDriver driver = new FirefoxDriver(); driver.get("http://www.homeshop18.com/fashion-jewellery/category:15143/filter_Theme:%28%22Traditional+Wear%22+%22Cuff+%26+Kada%22+%22Daily+Wear%22+%22Maang+Tikka%22+%22Openable+Round%22+%22Round%22+%22Openable+Oval%22%29/sort:Popularity/inStock:true/?it_category=HP&it_action=JW-HPSP01&it_label=HP-HPSP01-131021235900-PD-JW-ZC-VK-SC_DiwaliFestWeddingJewellery&it_value=0"); WebElement Slider = driver.findElement(By.xpath("//*[@id='slider-range']/a[1]")); Thread.sleep(3000); Actions moveSlider = new Actions(driver); Action action = moveSlider.dragAndDropBy(Slider, 30, 0).build(); action.perform();
WebDriver driver = new FirefoxDriver(); driver.get("http://www.homeshop18.com/fashion-jewellery/category:15143/filter_Theme:%28%22Traditional+Wear%22+%22Cuff+%26+Kada%22+%22Daily+Wear%22+%22Maang+Tikka%22+%22Openable+Round%22+%22Round%22+%22Openable+Oval%22%29/sort:Popularity/inStock:true/?it_category=HP&it_action=JW-HPSP01&it_label=HP-HPSP01-131021235900-PD-JW-ZC-VK-SC_DiwaliFestWeddingJewellery&it_value=0"); WebElement slider = driver.findElement(By.xpath("//*[@id='slider-range']/a[1]")); Thread.sleep(3000); Actions moveSlider = new Actions(driver); Action action = moveSlider.dragAndDropBy(slider, 30, 0).build(); action.perform();
public class TestClass { public static void main(String[] args) { File file = new File("D:\\Driver\\IEDriverServer.exe"); System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); WebDriver driver = new InternetExplorerDriver(); driver.get("http://jqueryui.com/slider/"); WebDriver driver = new InternetExplorerDriver(); driver.get("http://jqueryui.com/slider/"); driver.switchTo().frame(0); //need to switch to this frame before clicking the slider WebElement slider = driver.findElement(By.xpath("//div[@id='slider']/span")); Actions move = new Actions(driver); Action action = (Action) move.dragAndDropBy(slider, 30, 0).build(); action.perform(); }
Actions slide = new Actions(driver); WebElement text=obj.findElementByXpath(".//[@id='chartContainer']/div/canvas[2]"); slide.build(); text.click(); slide.dragAndDropBy(text, 100, 4500); slide.perform(); slide.release(); }
/** * Drags an element a certain distance and then drops it. * * @param element to dragAndDrop * @param offsetX in pixels from the current location to which the element should be moved, e.g., 70 * @param offsetY in pixels from the current location to which the element should be moved, e.g., -300 */ public void dragAndDrop(final HtmlElement element, final int offsetX, final int offsetY) { new Actions(driver).dragAndDropBy((WebElement) element.getElement(), offsetX, offsetY).perform(); }
@JDIAction("Drag '{name}' and drop it to ({0},{1})") public void dragAndDropTo(int x, int y) { doActions(a -> a.dragAndDropBy(get(), x, y)); } private Actions actions = null;
@Override public void dragAndDrop(String locatorFrom, int xOffset, int yOffset) { getBuilder().dragAndDropBy(waitForElement(locatorFrom), xOffset, yOffset).perform(); }
public void dragAndDropBy(int x, int y) { invoker.doJAction(format("Drag and drop Element: (x,y)=(%s,%s)", x, y), () -> new Actions(getDriver()).dragAndDropBy(getWebElement(), x, y).build().perform()); }
@Override protected Void action(WebKey key, Object... param) throws ExecutionException { WebElement from = fetcher.fetchElement(key); Offset offset = (Offset) param[0]; Actions actions = new Actions(driver); actions.dragAndDropBy(from, offset.xOffset(), offset.yOffset()); actions.perform(); return null; } };
public void dragAndDropBy(int xOffset, int yOffset) { Actions actions = new Actions(webDriver); actions.dragAndDropBy(element, xOffset, yOffset); actions.perform(); }
private void dragAndDropWithOffset(final WebElement source, final WebElement target, final int offset) { Point currentLocation = source.getLocation(); Point destination = target.getLocation(); // We need to ensure we have the source in view. An egrgarious hack to make sure we can do this. // Assumes that scrolling to the top of the page will have our source AND target in the viewable area driver.findElement(By.tagName("body")).getSize(); int xOffset = destination.x - currentLocation.x + 1; int yOffset = destination.y - currentLocation.y + offset; Actions action = new Actions(driver).dragAndDropBy(source, xOffset, yOffset); action.perform(); }
public void dragAndDropByOffset(String locatorSrc, int xOffset, int yOffset) { LOG.keywordAppender() .appendLocator(locatorSrc) .appendArgument("xOffset", xOffset) .appendArgument("yOffset", yOffset); WebElement element = finder.find(locatorSrc); new Actions(driver).dragAndDropBy(element, xOffset, yOffset).perform(); }
public void move_by(int x, int y) { takeScreenshot(); Point current_location = getLocation(); action("Current position of element '" + current_location + "', Moving by (x, y) = (" + x + ", " + y + ")"); Actions drag = new Actions(browser.driver()); try { drag.dragAndDropBy(_nativeWebElement(), x, y).build().perform(); Point new_location = getLocation(); action("New position of element '" + new_location + "', Moved by (x, y) = (" + x + ", " + y + ")"); } catch (org.openqa.selenium.interactions.MoveTargetOutOfBoundsException mtoobe) { error("Cannot move element '" + current_location + "', to (x, y) = (" + x + ", " + y + "), got org.openqa.selenium.interactions.MoveTargetOutOfBoundsException"); } takeScreenshot(); }
public void moveTabAfter(final String tab, final String target) { Tracer tracer = traceContext.checkpoint(); final WebElement sourceDragHandle = getDragHandle(tab); final WebElement targetDragHandle = getDragHandle(target); final WebElement targetTabElement = driver.findElement(By.cssSelector(".menu-item[data-name='" + target + "']")); int widthOffset = (int) (targetTabElement.getSize().getWidth() / 2.0); Point sourceLocation = sourceDragHandle.getLocation(); Point targetLocation = targetDragHandle.getLocation(); Actions action = new Actions(driver).dragAndDropBy(sourceDragHandle, targetLocation.x - sourceLocation.x + widthOffset, 0); action.perform(); traceContext.waitFor(tracer, "screen.tab.order.updated"); }
@Override protected void doPerform() { WebElement targetElem = getFirstElement(target); if (targetOffset == null) { getActions().dragAndDrop(getFirstElement(), targetElem).perform(); } else { org.openqa.selenium.Dimension size = targetElem.getSize(); Dimension dimension = new Dimension(size.width, size.height); Point offsetPoint = targetOffset.offset(dimension); getActions().dragAndDropBy(getFirstElement(), offsetPoint.x(), offsetPoint.y()).perform(); } } }
private void resizeMedia(int xOffSet, int yOffset) { Log.log("resizeMedia", "Before resizing", true, driver); selectMedia(); wait.forElementVisible(swResizeHandle); Actions actions = new Actions(driver); actions.dragAndDropBy(swResizeHandle, xOffSet, yOffset).build().perform(); Log.log("resizeMedia", "After resizing", true, driver); }