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

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

Introduction

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

Prototype

public Actions(WebDriver driver) 

Source Link

Usage

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void doubleClick() {
    doJAction("Couble click on element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.doubleClick();/*  w w w .j ava 2  s .  com*/
    });
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void rightClick() {
    doJAction("Right click on element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.contextClick(getWebElement()).perform();
    });/*ww w  .j a va  2s  .co m*/
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void clickCenter() {
    doJAction("Click in Center of element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.click(getWebElement()).perform();
    });/*  w  w  w .ja v  a  2  s.c  o m*/
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void mouseOver() {
    doJAction("Move mouse over element", () -> {
        getWebElement().getSize(); //for scroll to object
        Actions builder = new Actions(getDriver());
        builder.moveToElement(getWebElement()).build().perform();
    });// ww w . j  a  va2s .c  o m
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void focus() {
    doJAction("Focus on element", () -> {
        Dimension size = getWebElement().getSize(); //for scroll to object
        new Actions(getDriver()).moveToElement(getWebElement(), size.width / 2, size.height / 2).build()
                .perform();//from w  ww  . j  a  v  a  2  s  .co m
    });
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void selectArea(int x1, int y1, int x2, int y2) {
    doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> {
        WebElement element = getWebElement();
        new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold().moveToElement(element, x2, y2)
                .release().build().perform();
    });/*  ww w. j  a  v  a2s .  c  o m*/
}

From source file:com.ggasoftware.jdi_ui_tests.elements.base.Element.java

License:Open Source License

public void dragAndDropBy(int x, int y) {
    doJAction(format("Drag and drop element: (x,y)=(%s,%s)", x, y),
            () -> new Actions(getDriver()).dragAndDropBy(getWebElement(), x, y).build().perform());
}

From source file:com.ggasoftware.uitest.control.Element.java

License:Open Source License

/**
 * A convenience method that performs click at the location of the source element
 *
 * @param xOffset - horizontal move offset.
 * @param yOffset - vertical move offset.
 * @return Parent instance//from w  w  w .  j  a  va  2  s.  c  o  m
 */
public ParentPanel clickBy(int xOffset, int yOffset) {
    doJAction(format("click element:  horizontal move offset- %dpx; vertical move offset- %dpx", xOffset,
            yOffset), () -> {
                Actions builder = new Actions(getDriver());
                Action click = builder.moveToElement(getWebElement(), xOffset, yOffset).click().build();
                click.perform();
            });
    return parent;
}

From source file:com.ggasoftware.uitest.control.Element.java

License:Open Source License

/**
 * Click on the Element(WebElement) with pressed CTRL key
 *
 * @return Parent instance/*from ww  w.ja  v a2 s  .  co m*/
 */
public ParentPanel ctrlClick() {
    doJAction("ctrlClick", () -> new Actions(getDriver()).keyDown(Keys.CONTROL).moveToElement(getWebElement())
            .click().keyUp(Keys.CONTROL).perform());
    return parent;
}

From source file:com.ggasoftware.uitest.control.Element.java

License:Open Source License

/**
 * Performs a double-click at the current mouse location.
 *
 * @return Parent instance/*from  ww w.  java2 s  .c om*/
 */
public ParentPanel doubleClick() {
    getWebElement().getSize(); //for scroll to object
    logAction(this, getParentClassName(), "doubleClick");
    alwaysDoneAction(() -> {
        Actions builder = new Actions(getDriver());
        builder.doubleClick();
    });
    return parent;
}