aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/ui/UIPollingTest.java
blob: c4a41d135aeaf60d7dc6bc65bffc5ef147a1f9d0 (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
package com.vaadin.tests.components.ui;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

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

public class UIPollingTest extends MultiBrowserTest {

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        // Manually testing IE8 stops polling with -1, but with automated test
        // it seems to be highly unpredictable.
        return super.getBrowsersExcludingIE8();
    }

    @Test
    public void testPolling() throws Exception {
        openTestURL();
        getTextField().setValue("500");
        sleep(2000);
        /* Ensure polling has taken place */
        Assert.assertTrue("Page does not contain the given text", driver
                .getPageSource().contains("2. 1000ms has passed"));
        getTextField().setValue("-1");
        sleep(2000);
        /* Ensure polling has stopped */
        Assert.assertFalse("Page contains the given text", driver
                .getPageSource().contains("20. 10000ms has passed"));
    }

    public TextFieldElement getTextField() {
        return $(TextFieldElement.class).first();
    }
}