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

import static org.junit.Assert.assertTrue;

import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;

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

public class ComboBoxPopupPositionEmbeddedInDivTest extends MultiBrowserTest {

    @Test
    public void popupBelow() {
        driver.get(StringUtils.strip(getBaseURL(), "/")
                + "/statictestfiles/ComboBoxEmbeddingHtmlPage.html");

        // Chrome requires document.scrollTop (<body>)
        // Firefox + IE wants document.documentElement.scrollTop (<html>)
        executeScript(
                "document.body.scrollTop=200;document.documentElement.scrollTop=200;document.body.scrollLeft=50;document.documentElement.scrollLeft=50;");

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

        Point comboboxLocation = combobox.getLocation();
        Point popupLocation = popup.getLocation();
        assertTrue("Popup should be below combobox",
                popupLocation.getY() > comboboxLocation.getY());

        assertTrue("Popup should be left aligned with the combobox",
                popupLocation.getX() == comboboxLocation.getX());
    }

    @Override
    protected Class<?> getUIClass() {
        return ComboBoxEmbeddedInDiv.class;
    }
}