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

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

Introduction

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

Prototype

public Action build() 

Source Link

Document

Generates a composite action containing all actions so far, ready to be performed (and resets the internal builder state, so subsequent calls to #build() will contain fresh sequences).

Usage

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void doubleClick(String locator) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.doubleClick(webElement);//from w  w w .  j  ava  2  s . c  o  m

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void doubleClickAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (Validator.isNotNull(coordString) && coordString.contains(",")) {
        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);

        actions.doubleClick();// w  w  w .ja  v  a2 s .  c  o m
    } else {
        actions.doubleClick(webElement);
    }

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void dragAndDropToObject(String locatorOfObjectToBeDragged, String locatorOfDragDestinationObject) {

    WebElement objectToBeDraggedWebElement = getWebElement(locatorOfObjectToBeDragged);

    WrapsDriver wrapsDriver = (WrapsDriver) objectToBeDraggedWebElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    WebElement dragDestinationObjectWebElement = getWebElement(locatorOfDragDestinationObject);

    actions.dragAndDrop(objectToBeDraggedWebElement, dragDestinationObjectWebElement);

    Action action = actions.build();

    action.perform();/*from   w  w w .ja v a 2 s  .c  om*/
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void keyDown(String locator, String keySequence) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    String keycode = keySequence.substring(1);

    Keys keys = Keys.valueOf(keycode);/*  w  w  w. j av a  2s . c o  m*/

    actions.keyDown(webElement, keys);

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void keyPress(String locator, String keySequence) {
    WebElement webElement = getWebElement(locator);

    if (keySequence.startsWith("\\")) {
        String keycode = keySequence.substring(1);

        if (isValidKeycode(keycode)) {
            Keys keys = Keys.valueOf(keycode);

            WrapsDriver wrapsDriver = (WrapsDriver) webElement;

            WebDriver webDriver = wrapsDriver.getWrappedDriver();

            Actions actions = new Actions(webDriver);

            if (keycode.equals("ALT") || keycode.equals("COMMAND") || keycode.equals("CONTROL")
                    || keycode.equals("SHIFT")) {

                actions.keyDown(webElement, keys);
                actions.keyUp(webElement, keys);

                Action action = actions.build();

                action.perform();// w  ww . j a  v  a 2  s. c  om
            } else {
                webElement.sendKeys(keys);
            }
        }
    } else {
        webElement.sendKeys(keySequence);
    }
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void keyUp(String locator, String keySequence) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    String keycode = keySequence.substring(1);

    Keys keys = Keys.valueOf(keycode);/* ww  w  .j ava2 s. c om*/

    actions.keyUp(webElement, keys);

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void mouseDown(String locator) {
    WebElement webElement = getWebElement(locator);

    scrollWebElementIntoView(webElement);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.moveToElement(webElement);/*www.  j  a  v a  2  s. c  o m*/

    actions.clickAndHold(webElement);

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void mouseDownAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    scrollWebElementIntoView(webElement);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (Validator.isNotNull(coordString) && coordString.contains(",")) {
        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);

        actions.clickAndHold();/*  ww w  . j ava2 s.  c  o m*/
    } else {
        actions.moveToElement(webElement);

        actions.clickAndHold(webElement);
    }

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void mouseMove(String locator) {
    WebElement webElement = getWebElement(locator);

    scrollWebElementIntoView(webElement);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.moveToElement(webElement);/*from   w  w w  .  ja  v a 2  s  . c  om*/

    Action action = actions.build();

    action.perform();
}

From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java

License:Open Source License

@Override
public void mouseMoveAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    scrollWebElementIntoView(webElement);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (Validator.isNotNull(coordString) && coordString.contains(",")) {
        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);
    } else {//from   ww w .  j  a va 2s  . com
        actions.moveToElement(webElement);
    }

    Action action = actions.build();

    action.perform();
}