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.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java

License:Open Source License

@Test
public void testRendered() throws InterruptedException {

    dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
    dragIndicatorAttributes.set(rendered, true);

    // before any mouse move, no indicator appears on page
    elementNotPresent.element(page.indicator).apply(driver);

    Actions actionQueue = new Actions(driver);

    // firstly just drag and don't move. Indicator no displayed
    Action dragging = actionQueue.clickAndHold(page.drag1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();//  w  ww . j  a  va 2s  . c  om
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

    // simulate drop
    dragging = actionQueue.release().build();
    elementPresent.element(page.indicator);
    dragging.perform();
    elementNotPresent.element(page.indicator).apply(driver);

    // and now the same with indicator not rendered
    dragIndicatorAttributes.set(rendered, false);
    elementNotPresent.element(page.indicator).apply(driver);

    // just small move to attempt display indicator
    dragging = actionQueue.clickAndHold(page.drag1).moveByOffset(1, 1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator);

}

From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java

License:Open Source License

@Test
public void testDragging() {

    dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
    dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS);

    Actions actionQueue = new Actions(driver);

    // before any mouse move, no indicator appears on page
    elementNotPresent.element(page.indicator).apply(driver);

    // firstly just drag and don't move. Indicator no displayed
    Action dragging = actionQueue.clickAndHold(page.drag1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();//from  ww  w .j  a  v a2 s .c om
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

    // then move out of drag area (but not over drop area)
    dragging = actionQueue.moveByOffset(550, 10).build();
    dragging.perform();
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

    // this one as well
    dragging = actionQueue.release().build();
    dragging.perform();
    elementNotPresent.element(page.indicator);
}

From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java

License:Open Source License

@Test
public void testAccepting() {

    dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
    dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS);

    Actions actionQueue = new Actions(driver);

    Action dragging = actionQueue.clickAndHold(page.drag1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();//from w w w .j  a va  2s  .c  o  m
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

    dragging = actionQueue.moveToElement(page.drop1).build();
    dragging.perform();
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(ACCEPT_CLASS));

    // then release
    dragging = actionQueue.release().build();
    dragging.perform();
    elementNotPresent.element(page.indicator);
}

From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java

License:Open Source License

@Test
public void testRejecting() {
    dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
    dragIndicatorAttributes.set(rejectClass, REJECT_CLASS);

    Actions actionQueue = new Actions(driver);

    Action dragging = actionQueue.clickAndHold(page.drag1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();/*from w ww. j a  v a  2s  .co  m*/
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

    dragging = actionQueue.moveToElement(page.drop2).build();
    dragging.perform();
    assertTrue(page.indicator.isDisplayed());
    assertTrue(page.indicator.getAttribute("class").contains(REJECT_CLASS));

    // then release
    dragging = actionQueue.release().build();
    dragging.perform();
    elementNotPresent.element(page.indicator);
}

From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java

License:Open Source License

@Test
public void testMovingOverDifferentStates() {
    dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS);
    dragIndicatorAttributes.set(rejectClass, REJECT_CLASS);
    dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS);

    for (int i = 0; i <= 20; ++i) {
        Actions actionQueue = new Actions(driver);

        Action dragging = actionQueue.clickAndHold(page.drag1).build();
        dragging.perform();
        elementNotPresent.element(page.indicator);

        // just small move to display indicator
        dragging = actionQueue.moveByOffset(1, 1).build();
        dragging.perform();//from   ww w  .j av  a 2  s  .c o m
        assertTrue(page.indicator.isDisplayed());
        assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

        // then move out of drag area (but not over drop area)
        dragging = actionQueue.moveByOffset(550, 10).build();
        dragging.perform();
        assertTrue(page.indicator.isDisplayed());
        assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS));

        dragging = actionQueue.moveToElement(page.drop1).build();
        dragging.perform();
        assertTrue(page.indicator.isDisplayed());
        assertTrue(page.indicator.getAttribute("class").contains(ACCEPT_CLASS));

        dragging = actionQueue.moveToElement(page.drop2).build();
        dragging.perform();
        assertTrue(page.indicator.isDisplayed());
        assertTrue(page.indicator.getAttribute("class").contains(REJECT_CLASS));

        // then release
        dragging = actionQueue.release().build();
        dragging.perform();
        elementNotPresent.element(page.indicator);
    }

}

From source file:org.richfaces.tests.metamer.ftest.richDragSource.AbstractDragSourceTest.java

License:Open Source License

public void testDefaultIndicator() {

    indicator = new Indicator(page.defaultIndicator);
    indicator.setDefaultIndicator(true);
    dragSourceAttributes.set(dragIndicator, "");
    Actions actionQueue = new Actions(driver);

    Action clickAndHold = actionQueue.clickAndHold(page.drag1).build();
    clickAndHold.perform();
    assertTrue(elementNotPresent.element(page.defaultIndicator).apply(driver));

    Action move = actionQueue.moveByOffset(1, 1).build();
    move.perform();//  w  ww .  j a  va 2  s .c om
    assertTrue(elementPresent.element(page.defaultIndicator).apply(driver));

    testMovingOverDifferentStates();

    Action drop = actionQueue.release(page.drop1).build();
    drop.perform();

}

From source file:org.richfaces.tests.metamer.ftest.richDragSource.AbstractDragSourceTest.java

License:Open Source License

public void testRendered() {

    dragSourceAttributes.set(dragIndicator, "indicator2");
    dragSourceAttributes.set(rendered, true);

    // before any mouse move, no indicator appears on page
    elementNotPresent.element(page.indicator2).apply(driver);

    // indicator = new IndicatorWD(indicatorLoc);
    indicator = new Indicator(page.indicator2);
    Actions actionQueue = new Actions(driver);

    // firstly just drag and don't move. Indicator no displayed
    Action dragging = actionQueue.clickAndHold(page.drag1).build();
    dragging.perform();
    elementNotPresent.element(page.indicator2).apply(driver);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();//  w w w.j a  va 2  s . c  o m
    elementPresent.element(page.indicator2).apply(driver);

    dragging = actionQueue.release().build();
    elementPresent.element(page.indicator2).apply(driver);
    dragging.perform();
    elementNotPresent.element(page.indicator2).apply(driver);

}

From source file:org.richfaces.tests.metamer.ftest.webdriver.utils.StopWatch.java

License:Open Source License

public static StopWatch watchTimeSpentInAction(Action a) {
    long time = System.nanoTime();
    a.perform();
    return new StopWatch(System.nanoTime() - time);
}

From source file:org.richfaces.tests.showcase.dataTable.page.TableFilteringPage.java

License:Open Source License

protected void filterTextInput(WebElement input, String value, boolean valid) {
    input.click();/* w  ww.  ja va  2s  . c  o m*/
    input.clear();
    input.sendKeys(value);
    Action blur = valid ? Graphene.guardXhr(fireEventAction(input, "blur")) : fireEventAction(input, "blur");
    blur.perform();
}

From source file:org.richfaces.ui.chart.ITChartEvents.java

License:Open Source License

@RunAsClient
@Test/* w  ww  .  j a  v a2 s  . co  m*/
@Category(FailingOnFirefox.class)
public void ClientSideClick() {
    browser.get(deploymentUrl.toExternalForm());

    // click the first point in the first series of the chart
    Action click = builder.moveToElement(chartCanvas, chtestjs.pointXPos("frm:chart", 0, 0),
            chtestjs.pointYPos("frm:chart", 0, 0)).click().build();

    click.perform();

    // crop decimal places
    double xVal = chtestjs.pointX("frm:chart", 0, 0);
    int xValInt = (int) xVal;

    String expected = Integer.toString(xValInt) + ',' + Double.toString(chtestjs.pointY("frm:chart", 0, 0));

    Assert.assertEquals(expected, clickSpan.getText());
}