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

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

Introduction

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

Prototype

void perform();

Source Link

Usage

From source file:org.specrunner.webdriver.actions.PluginContextClick.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    Action ac = new Actions(client).contextClick(element).build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginDoubleClick.java

License:Open Source License

@Override
protected void doEnd(IContext context, IResultSet result, WebDriver client) throws PluginException {
    Action ac = new Actions(client).doubleClick().build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginDoubleClickOn.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    Action ac = new Actions(client).doubleClick(element).build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginDragAndDrop.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    if (getTarget() == null && getXoffset() == null && getYoffset() == null) {
        throw new PluginException(
                "To use drag and drop you should specify 'target' attribute using the same syntax of attribute 'by', or specify 'xoffset' and 'yoffset' attributes.");
    }/*w ww  .  j a va 2s  .  c  o  m*/
    Action ac = null;
    if (getTarget() != null) {
        IFinder finder = getFinderInstance();
        try {
            finder.getParameters().setParameter("by", getTarget(), context);
        } catch (Exception e) {
            throw new PluginException(e);
        }

        List<WebElement> list = finder.find(context, result, client);
        if (list.isEmpty()) {
            throw new PluginException("Element " + finder.resume(context) + " not found.");
        }
        WebElement destination = list.get(0);
        ac = new Actions(client).dragAndDrop(element, destination).build();
    } else if (getXoffset() == null && getYoffset() == null) {
        ac = new Actions(client).dragAndDropBy(element, getXoffset(), getYoffset()).build();
    } else {
        throw new PluginException("You should specify both 'xoffset' and 'yoffset' attributes.");
    }
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginMoveBy.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    if (getXoffset() == null && getYoffset() == null) {
        throw new PluginException("PluginMoveBy requires xoffset and yoffset attributes.");
    }/*from  ww w . j a va2 s.  co m*/
    Action ac = new Actions(client).moveByOffset(getXoffset(), getYoffset()).build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginMoveTo.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    Action ac = null;
    if (getXoffset() != null && getYoffset() != null) {
        ac = new Actions(client).moveToElement(element, getXoffset(), getYoffset()).build();
    } else {// w  w  w . ja  va 2  s  . c o  m
        ac = new Actions(client).moveToElement(element).build();
    }
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginRelease.java

License:Open Source License

@Override
protected void doEnd(IContext context, IResultSet result, WebDriver client) throws PluginException {
    Action ac = new Actions(client).release().build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.specrunner.webdriver.actions.PluginReleaseOn.java

License:Open Source License

@Override
protected void process(IContext context, IResultSet result, WebDriver client, WebElement element)
        throws PluginException {
    Action ac = new Actions(client).release(element).build();
    ac.perform();
    result.addResult(Success.INSTANCE, context.peek());
}

From source file:org.uiautomation.ios.selenium.interactions.touch.TouchDoubleTapTest.java

License:Apache License

private void doubleTapOnElement(String elementId) {
    WebElement toDoubleTap = driver.findElement(By.id(elementId));
    Action doubleTap = getBuilder(driver).doubleTap(toDoubleTap).build();
    doubleTap.perform();
}

From source file:org.uiautomation.ios.selenium.interactions.touch.TouchFlickTest.java

License:Apache License

@NeedsFreshDriver
@Test// www  . java 2  s .  co m
public void testCanFlickHorizontallyFromWebElement() {
    driver.get(pages.longContentPage);

    WebElement toFlick = driver.findElement(By.id("imagestart"));
    WebElement link = driver.findElement(By.id("link1"));
    int originalX = link.getLocation().x;
    // The element is located at the right of the page,
    // so it is not initially visible on the screen.
    Action flick = getBuilder(driver).flick(toFlick, -1000, 0, FlickAction.SPEED_NORMAL).build();
    flick.perform();

    int newX = link.getLocation().x;
    // After flicking, the element should now be visible on the screen.
    assertTrue("Expected x < " + originalX + ", but got x = " + newX, newX < originalX);
}