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

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

Introduction

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

Prototype

public void perform() 

Source Link

Document

A convenience method for performing the actions without calling build() first.

Usage

From source file:org.safs.selenium.webdriver.lib.interpreter.selrunner.steptype.AddSelection.java

License:Open Source License

@Override
protected boolean performSelect(WebElement select, WebElement option, TestRun ctx) {
    try {//from  w ww .  j a v  a 2 s . c  o  m
        Actions action = new Actions(ctx.driver());
        action.keyDown(Keys.CONTROL);
        action.perform();

        option.click();

        action = new Actions(ctx.driver());
        action.keyUp(Keys.CONTROL);
        action.perform();
        return true;
    } catch (Exception x) {
        ctx.log().error("Select Option CTRL+click " + x.getClass().getSimpleName() + ", " + x.getMessage());
        return false;
    }
}

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

License:Apache License

/**
 * Attempts a right click in the browser to show the context menu. Must be enabled in the client code, or no menu will be found
 * @see com.sencha.gxt.widget.core.client.TabPanel#setCloseContextMenu(boolean)
 *//*from  w  ww. j  a  v a2  s  .  c  om*/
public Menu rightClickTabWithText(String text) {
    List<WebElement> elements = getElement()
            .findElements(By.xpath(".//*[contains(text()," + escapeToString(text) + ")]"));
    for (WebElement elt : elements) {
        if (!elt.findElements(new FasterByChained(new ByNearestWidget(getDriver()),
                new ByWidget(getDriver(), com.sencha.gxt.widget.core.client.TabPanel.class))).isEmpty()) {
            Actions a = new Actions(getDriver());
            a.contextClick(elt);
            a.perform();
            return GwtWidget.find(Menu.class, getDriver()).atTop().done();
        }
    }
    throw new NoSuchElementException("No tab found with text '" + text + "'");
}

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  .j a v  a 2  s. co  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  va  2 s . c  o 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());
}

From source file:org.webtestingexplorer.actions.HoverAction.java

License:Open Source License

@Override
public void perform(WebDriverWrapper driver) {
    WebElement element = identifier.findElement(driver);
    Actions builder = new Actions(driver.getDriver());
    Actions hoverAction = builder.moveToElement(element);
    hoverAction.perform();
    try {//w w  w  . j  a v a2s  .c  o m
        Thread.sleep(hoverDelayMillis);
    } catch (InterruptedException e) {
    }
}