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

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

Introduction

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

Prototype

public Actions release() 

Source Link

Document

Releases the depressed left mouse button at the current mouse location.

Usage

From source file:org.senchalabs.gwt.gwtdriver.gxt.models.TreeDndTest.java

License:Apache License

@Test
public void testDragAndDrop() {
    Tree t = new Tree(driver, driver.findElement(new ByChained(By.xpath("//body/*"),
            new ByWidget(driver, com.sencha.gxt.widget.core.client.tree.Tree.class))));

    Item root = t.findItemWithText("root");
    root.toggleExpand();/*from w w w  .  ja  va  2 s .  c  o m*/
    Assert.assertEquals(2, root.getChildren().size());

    Item foo = root.getChildren().get(0);
    foo.toggleExpand();

    Item bar = foo.getChildren().get(0);
    foo.getElement();
    Actions a = new Actions(driver);
    a.clickAndHold(bar.getElement());
    a.moveToElement(root.getElement());
    a.release();

    a.perform();

    Assert.assertEquals(3, root.getChildren().size());

}

From source file:org.senchalabs.gwt.gwtdriver.gxt.models.TreeDndTest.java

License:Apache License

@Test
public void testDragExpandAndDrop() throws InterruptedException {
    Tree t = new Tree(driver, driver.findElement(new ByChained(By.xpath("//body/*"),
            new ByWidget(driver, com.sencha.gxt.widget.core.client.tree.Tree.class))));

    Item root = t.findItemWithText("root");
    Item other = t.getRootChildren().get(1);

    //drag, still holding
    Actions a = new Actions(driver);
    a.clickAndHold(other.getElement());/*  w  w w.j  a v a2  s. co  m*/
    a.moveToElement(root.getElement());
    a.perform();

    //wait until expanded (800ms by default, wait 1 second)
    Thread.sleep(1000);

    Assert.assertEquals(2, root.getChildren().size());
    Item foo = root.getChildren().get(0);

    a = new Actions(driver);
    a.moveToElement(foo.getElement());
    a.release();
    a.perform();

    Assert.assertEquals(1, t.getRootChildren().size());
    Assert.assertEquals(false, foo.isExpanded());
    Assert.assertEquals(2, root.getChildren().size());

    foo.toggleExpand();
    Assert.assertEquals(2, foo.getChildren().size());
}