aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAtRightEdgeTest.java
blob: e65d4ed12b876d9acf0fc6ff74d7c7b6acaef162 (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
package com.vaadin.tests.components.combobox;

import org.junit.Test;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class ComboBoxAtRightEdgeTest extends MultiBrowserTest {

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

        ComboBoxElement cb = $(ComboBoxElement.class).first();
        cb.openPopup();
        WebElement popup = cb.getSuggestionPopup();

        int cbRight = cb.getLocation().getX() + cb.getSize().getWidth();
        int popupRight = popup.getLocation().getX()
                + popup.getSize().getWidth();
        assertGreaterOrEqual(String.format(
                "Popup should not reach further right than the ComboBox at the "
                        + "right edge of the viewport. ComboBox: %s, Popup: %s",
                cbRight, popupRight), cbRight, popupRight);
    }
}