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.pivotal.gemfire.tools.pulse.tests.PulseTests.java

License:Open Source 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);
    // pickerscroll is the webelement
    Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
    movePicker.perform();/*from  ww  w.ja  va  2s .  c o m*/
}

From source file:com.pivotal.gemfire.tools.pulse.tests.PulseTests.java

License:Open Source License

protected void scrollbarHorizontalRightScroll() {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("javascript:window.scrollBy(250,700)");
    WebElement pickerScroll = driver//from www .j  a v a  2 s. co m
            .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);
    // pickerscroll is the webelement
    Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
    movePicker.perform();
}

From source file:com.raja.anucarita.SeCustomActions.java

License:Open Source License

public static void seDragAndDrop(WebDriver driver, String LeftElementLocator, String LeftElementReplace,
         String RightElementLocator, String RightElementReplace) throws Exception {
     String LeftLocator = SeCustomUtils.returnLocator(LeftElementLocator, LeftElementReplace);
     String RightLocator = SeCustomUtils.returnLocator(RightElementLocator, RightElementReplace);

     WebElement LeftElement = SeCustomUtils.elementReturn(driver, LeftLocator);
     WebElement RightElement = SeCustomUtils.elementReturn(driver, RightLocator);

     if (LeftElement instanceof WebElement && RightElement instanceof WebElement) {
         Actions builder = new Actions(driver);
         Action dragAndDrop = builder.dragAndDrop(LeftElement, RightElement).build();
         dragAndDrop.perform();//from w  ww . ja  va 2  s.  co m
     }
 }

From source file:com.smartqa.engine.WebEngine.java

License:Apache License

/**
 * drag and drop web element/*from  w ww .j a  v  a2  s  .com*/
 * 
 * @param srcName - name stands for source web element
 * @param destName - name stands for target web element
 * @return WebEngine
 */
public WebEngine dragAndDrop(String srcName, String destName) {
    WebElement srcElement = locate(srcName);
    WebElement destElement = locate(destName);

    Actions builder = new Actions(driver);
    builder.dragAndDrop(srcElement, destElement).build().perform();
    CommonUtils.waiting(speed);
    return this;
}

From source file:com.springer.omelet.driver.DriverUtility.java

License:Apache License

/***
 * Perform drag and drop//from  w  w w  . ja v  a  2 s  .c om
 * 
 * @param sourceElement
 *            :element which need to be dragged
 * @param targetElement
 *            :element on which dragged Element needs to be dropped
 * @param driver
 *            :WebDriver
 * @author kapilA
 */
public static void dragAndDrop(WebElement sourceElement, WebElement targetElement, WebDriver driver) {
    Actions a = new Actions(driver);
    a.dragAndDrop(sourceElement, targetElement).perform();
}

From source file:com.stratio.qa.specs.WhenGSpec.java

License:Apache License

/**
 * Searchs for two webelements dragging the first one to the second
 *
 * @param source//ww  w.  ja  v  a2  s  . c om
 * @param destination
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 * @throws SecurityException
 * @throws NoSuchFieldException
 * @throws ClassNotFoundException
 */
@When("^I drag '([^:]*?):([^:]*?)' and drop it to '([^:]*?):([^:]*?)'$")
public void seleniumDrag(String smethod, String source, String dmethod, String destination)
        throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException,
        IllegalAccessException {
    Actions builder = new Actions(commonspec.getDriver());

    List<WebElement> sourceElement = commonspec.locateElement(smethod, source, 1);
    List<WebElement> destinationElement = commonspec.locateElement(dmethod, destination, 1);

    builder.dragAndDrop(sourceElement.get(0), destinationElement.get(0)).perform();
}

From source file:com.sugarcrm.candybean.automation.control.VControl.java

License:Open Source License

/**
 * Drag this control and drop onto another control.
 *
 * @param dropControl  target of the drag and drop
 * @throws Exception    if either element cannot be found
 *///from   www. j  av  a 2  s .c om
public void dragNDrop(VControl dropControl) throws Exception {
    voodoo.log
            .info("Selenium: dragging control: " + this.toString() + " to control: " + dropControl.toString());
    Actions action = new Actions(this.iface.wd);
    action.dragAndDrop(this.we, dropControl.we).build().perform();
}

From source file:com.sugarcrm.candybean.automation.webdriver.WebDriverElement.java

License:Open Source License

/**
 * Drag this element and drop onto another element.
 * //from  w  ww.  j ava 2  s  .co  m
 * @param dropControl
 *            target of the drag and drop
 */
public void dragNDrop(WebDriverElement dropControl) throws CandybeanException {
    logger.info("Dragging element: " + this.toString() + " to element: " + dropControl.toString());
    Actions action = new Actions(this.wd);
    action.dragAndDrop(this.we, dropControl.we).build().perform();
}

From source file:com.vmware.gemfire.tools.pulse.tests.PulseAbstractTest.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 web element
    movePicker.perform();//from   www .  j  av  a 2  s . c om
}

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

License:Apache License

protected void scrollbarHorizontalRightScroll() {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("javascript:window.scrollBy(250,700)");
    WebElement pickerScroll = driver/*from www .  j av a  2 s .c  o  m*/
            .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 web element
    movePicker.perform();
}