aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java
blob: dccd1362de6db47a4c91717c6f33a1a0a8458541 (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
package com.vaadin.tests.layouts.layouttester.HLayout;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.util.List;

import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.HorizontalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseIconTest;

public class HIconTest extends BaseIconTest {

    @Override
    public void LayoutIcon() throws IOException {
        super.LayoutIcon();

        // The layout is too wide to fit into one screenshot, we need to scroll
        // and take another.

        List<HorizontalLayoutElement> layouts = $(HorizontalLayoutElement.class)
                .all();
        assertEquals(8, layouts.size());
        HorizontalLayoutElement lastOfRow1 = layouts.get(3);
        HorizontalLayoutElement lastOfRow2 = layouts.get(7);

        // scroll to both to ensure both contents are fully in view,
        // moveToElement fails on Firefox since the component is out of viewport
        ((JavascriptExecutor) driver).executeScript(
                "arguments[0].scrollIntoView(true);", lastOfRow1);
        ((JavascriptExecutor) driver).executeScript(
                "arguments[0].scrollIntoView(true);", lastOfRow2);

        compareScreen("icon-scrolled");
    }
}