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

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

Introduction

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

Prototype

public Actions clickAndHold(WebElement target) 

Source Link

Document

Clicks (without releasing) in the middle of the given element.

Usage

From source file:org.openecomp.sdc.ci.tests.execute.resourceui.VFCanvasTest.java

License:Open Source License

@Test
public void VFCanvasTest1() throws Exception {
    // GeneralUIUtils.waitForContainsdataTestIdVisibility("left-sectioin-element-QA");

    GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION);
    Thread.sleep(2000);//from w  ww.j  a va  2s .c  o m
    List<Integer> position = null;
    WebElement canvas = GeneralUIUtils.getWebElementWaitForVisible("canvas");
    int xPos = 0;
    int yPos = 0;
    position = getposition(canvas, xPos, yPos);
    WebElement otherElement = GeneralUIUtils
            .getWebElementWaitForVisible("left-sectioin-element-QA left-section-NeutronPort");
    for (int i = 0; i < 8; i++) {
        Actions builder = new Actions(GeneralUIUtils.getDriver());
        Action dragAndDrop = builder.clickAndHold(otherElement)
                .moveToElement(canvas, position.get(0), position.get(1)).release().build();
        dragAndDrop.perform();
        Thread.sleep(2000);
    }
    Thread.sleep(2000);
    Actions builder = new Actions(GeneralUIUtils.getDriver());
    builder.moveToElement(canvas, position.get(0), position.get(1));
    builder.clickAndHold();
    position = getposition(canvas, xPos, yPos);
    builder.moveToElement(canvas, position.get(0), position.get(1));
    builder.release();
    builder.build();
    builder.perform();
    builder.moveToElement(canvas, 200, 300);
    builder.release();
    builder.perform();

}

From source file:org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils.java

License:Open Source License

public void moveResourceInstanceToCanvasUI() throws Exception {
    List<WebElement> moveResource = driver.findElements(By.className("sprite-resource-icons"));
    WebElement moveResourceToCanvasResourceOne = moveResource.get(0);
    // WebElement moveResource =
    // driver.findElement(By.className("sprite-resource-icons"));
    Actions action = new Actions(driver);
    action.moveToElement(moveResourceToCanvasResourceOne);
    action.clickAndHold(moveResourceToCanvasResourceOne);
    action.moveByOffset(635, 375);//  w ww . j  a v  a 2s.com
    action.release();
    action.perform();
    WebElement moveResourceToCanvasResourceTwo = moveResource.get(1);
    action.moveToElement(moveResourceToCanvasResourceTwo);
    action.clickAndHold(moveResourceToCanvasResourceTwo);
    action.moveByOffset(535, 375);
    action.release();
    action.perform();
    WebElement moveResourceToCanvasResourceTree = moveResource.get(2);
    action.moveToElement(moveResourceToCanvasResourceTree);
    action.clickAndHold(moveResourceToCanvasResourceTree);
    action.moveByOffset(435, 375);
    action.release();
    action.perform();
    Thread.sleep(2000);
}

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();// ww  w .  j a va 2 s . c  om
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();
    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();//from   w  ww  .  j  av  a 2  s  . co  m
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();
    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();/*from w ww  .  jav a 2  s.co  m*/
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).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));

    // 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();/*  w  w w . j  a  va 2 s.c  om*/
    elementNotPresent.element(page.indicator);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();
    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();//from   w w  w.j a  v  a 2  s  .  c om
        elementNotPresent.element(page.indicator);

        // just small move to display indicator
        dragging = actionQueue.moveByOffset(1, 1).build();
        dragging.perform();
        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();/*from w ww. j  ava 2  s. c o  m*/
    assertTrue(elementNotPresent.element(page.defaultIndicator).apply(driver));

    Action move = actionQueue.moveByOffset(1, 1).build();
    move.perform();
    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();//from   w  w  w .j  a v a  2 s .c  om
    elementNotPresent.element(page.indicator2).apply(driver);

    // just small move to display indicator
    dragging = actionQueue.moveByOffset(1, 1).build();
    dragging.perform();
    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.richDragSource.TestDragSource.java

License:Open Source License

@Test
@IssueTracking({ "https://issues.jboss.org/browse/RF-12441", "https://issues.jboss.org/browse/RF-14081",
        "https://issues.jboss.org/browse/RF-14229" })
@Uses({ @UseWithField(field = "indicatorValue", valuesFrom = ValuesFrom.STRINGS, value = { "", "indicator",
        "indicator2" }),
        @UseWithField(field = "dragOptionsValue", valuesFrom = ValuesFrom.STRINGS, value = { "",
                "predefinedWithHelper", "predefinedWithoutHelper" }) })
@CoversAttributes({ "dragIndicator", "dragOptions" })
public void testDragIndicatorAndOptions() {
    // setup attributes
    attsSetter().setAttribute("dragIndicator").toValue(indicatorValue).setAttribute("dragOptions")
            .toValue(dragOptionsValue).asSingleAction().perform();
    // setup indicator
    boolean isDragOptionsWithHelper = dragOptionsValue.equals("predefinedWithHelper");
    boolean isDefaultIndicatorUsed = indicatorValue.isEmpty() || isDragOptionsWithHelper;
    GrapheneElement indicatorElement = isDefaultIndicatorUsed ? getPage().getDefaultIndicatorElement()
            : indicatorValue.equals("indicator") ? getPage().getIndicatorElement()
                    : getPage().getIndicator2Element();
    indicator = new Indicator(indicatorElement);
    indicator.setDefaultIndicator(isDefaultIndicatorUsed);
    // check no errors are present in browser's console
    assertEquals(jsErrorStorage.getMessages().size(), 0);

    Actions actionQueue = new Actions(driver);
    try {/*from w  w w.  j a  v  a 2 s . c o  m*/
        actionQueue.clickAndHold(getPage().getDrag1Element()).moveByOffset(1, 1).perform();
        assertTrue(indicatorElement.isPresent());

        if (!dragOptionsValue.isEmpty()) {
            // check indicator has predefined properties from @dragOptions
            for (Entry<String, String> e : dragOptionsValueMap.get(dragOptionsValue)) {
                // when using DragOptionsWithoutHelper, the opacity is used from the indicator
                if (!e.getKey().equals("opacity") || isDragOptionsWithHelper) {
                    assertEquals(indicatorElement.getCssValue(e.getKey()), e.getValue());
                }
            }
        }
        // check it is working
        testMovingOverDifferentStates();
    } finally {
        actionQueue.release(getPage().getDrop1Element()).perform();
    }
    // check no errors are present in browser's console
    assertEquals(jsErrorStorage.getMessages().size(), 0);
}