Example usage for org.openqa.selenium.interactions Actions dragAndDrop

List of usage examples for org.openqa.selenium.interactions Actions dragAndDrop

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions dragAndDrop.

Prototype

public Actions dragAndDrop(WebElement source, WebElement target) 

Source Link

Document

A convenience method that performs click-and-hold at the location of the source element, moves to the location of the target element, then releases the mouse.

Usage

From source file:com.vmware.gemfire.tools.pulse.tests.PulseTest.java

License:Apache License

protected void scrollbarVerticalDownScroll() {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("javascript:window.scrollBy(250,700)");
    WebElement pickerScroll = driver.findElement(By.className("jspDrag"));
    WebElement pickerScrollCorner = driver.findElement(By.className("jspCorner"));
    Actions builder = new Actions(driver);
    Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner); // pickerscroll
                                                                                // is
                                                                                // the
                                                                                // webelement
    movePicker.perform();/*w  ww  .  j a va 2s  .c o m*/
}

From source file:com.vmware.gemfire.tools.pulse.tests.PulseTest.java

License:Apache License

protected void scrollbarHorizontalRightScroll() {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("javascript:window.scrollBy(250,700)");
    WebElement pickerScroll = driver//from  w  ww .  j  ava 2  s.  com
            .findElement(By.xpath("//div[@id='gview_queryStatisticsList']/div[3]/div/div[3]/div[2]/div"));
    WebElement pickerScrollCorner = driver.findElement(By.className("jspCorner"));
    Actions builder = new Actions(driver);
    Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner); // pickerscroll
                                                                                // is
                                                                                // the
                                                                                // webelement
    movePicker.perform();
}

From source file:org.craftercms.web.basic.ComponentTest.java

@Test
public void testDragAndDrop() throws InterruptedException {
    String image = "/requiredImage.png";

    // Navigate to About page
    //driver.navigate().to(seleniumProperties.getProperty("craftercms.base.url") + aboutPage);
    CStudioSeleniumUtil.navigateToAndWaitForPageToLoad(driver,
            seleniumProperties.getProperty("craftercms.base.url") + aboutPage);

    CStudioSeleniumUtil.clickOn(driver, By.cssSelector("#acn-preview-tools-container"));

    new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {
        @Override//from ww w.ja v a2  s  .com
        public Boolean apply(WebDriver d) {
            return d.findElement(By.cssSelector("#preview-tools-panel-container")).isDisplayed();
        }
    });

    List<WebElement> options = (new WebDriverWait(driver, 10)).until(ExpectedConditions
            .presenceOfAllElementsLocatedBy(By.cssSelector("#preview-tools-panel-container .contracted")));

    options.get(1).click();

    new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver d) {
            return d.findElement(By.id("placeholder-zone-bottomPromos1")).isDisplayed();
        }
    });

    WebElement source = driver.findElement(By.id("yui-gen4"));
    WebElement target = driver.findElement(By.id("bottomPromos1"));

    Actions builder = new Actions(driver);
    Action dragAndDrop = builder.dragAndDrop(source, target).build();
    dragAndDrop.perform();

    WebElement element = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.presenceOfElementLocated(By.id("in-context-edit-editor")));
    //Check the modal window
    assertTrue(element != null);

    driver.switchTo().frame(element);

    //Upload an Image
    CStudioSeleniumUtil.clickOn(driver, By.cssSelector("#image input[value='Add']"));

    element = (new WebDriverWait(driver, 10))
            .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#cstudio-wcm-popup-div")));
    //Check the modal window
    assertTrue(element != null);

    driver.findElement(By.cssSelector("#uploadFileNameId")).sendKeys(assetsPath + image);
    driver.findElement(By.cssSelector("#uploadButton")).click();

    new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver d) {
            return !d.findElement(By.cssSelector("#image .datum")).getAttribute("value").isEmpty();
        }
    });

    driver.findElement(By.cssSelector("#cstudioSaveAndClose")).click();

    driver.switchTo().defaultContent();
}

From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java

License:Apache License

@Override
public void dragAndDrop(IElement element) throws WidgetException {
    try {//from ww  w .j  a v  a2 s.co m
        Actions builder = new Actions(getGUIDriver().getWrappedDriver());
        synchronized (InteractiveElement.class) {
            getGUIDriver().focus();
            builder.dragAndDrop(this.getWebElement(),
                    new InteractiveElement(element.getLocator()).getWebElement()).build().perform();
        }
    } catch (Exception e) {
        throw new WidgetException(
                "Error while performing drag and drop from " + getLocator() + " to " + element.getLocator(),
                getLocator(), e);
    }
}