aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java
blob: b0a38526b9faf67fdae375f6b6c56da82ec0bc82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.vaadin.tests.components.table;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
 * Tests whether right-click on a column header works after the column is
 * dragged.
 *
 * @author Vaadin Ltd
 */
public class HeaderRightClickAfterDragTest extends MultiBrowserTest {

    @Test
    public void dragAndRightClick() {
        openTestURL();

        waitForElementPresent(By.className("v-table"));

        TableElement table = $(TableElement.class).first();
        TestBenchElement header0 = table.getHeaderCell(0);
        Actions actions = new Actions(getDriver());
        actions.contextClick(header0).perform();

        // check that right-click opened a window
        waitForElementPresent(By.className("v-window"));

        closeWindow();

        actions.clickAndHold(header0).moveToElement(table.getHeaderCell(1))
                .release();

        actions.contextClick(header0).perform();

        // check that right-click still opened a window
        waitForElementPresent(By.className("v-window"));
    }

    private void closeWindow() {
        WindowElement window = $(WindowElement.class).first();
        window.findElement(By.className("v-window-closebox")).click();
        waitUntil(input -> findElements(By.className("v-window")).isEmpty());
    }
}