aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/fieldgroup/BooleanTextFieldTest.java
blob: e5ff31f9e1b99d4012deea77f2205f28fe210c14 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.vaadin.tests.fieldgroup;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.List;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.remote.DesiredCapabilities;

public class BooleanTextFieldTest extends BasicPersonFormTest {

    @Override
    protected boolean requireWindowFocusForIE() {
        return true;
    }

    @Test
    public void testSetBooleanTextField() throws Exception {
        openTestURL();

        getLastNameArea().clear();
        getLastNameArea().click();
        getLastNameArea().sendKeys("Dover");

        assertBeanValuesUnchanged();

        getDeceasedField().click();
        while (!getDeceasedField().getValue().isEmpty()) {
            getDeceasedField().sendKeys(Keys.BACK_SPACE);
        }
        getDeceasedField().sendKeys("false", Keys.ENTER);

        /* error indicator */
        assertEquals("Incorrect amount of error indicators on page.", 1,
                findElements(By.className("v-errorindicator")).size());
        assertEquals("false", getDeceasedField().getAttribute("value"));

        assertBeanValuesUnchanged();

        /* error message in tooltip */
        getDeceasedField().showTooltip();
        assertEquals("Could not convert value to Boolean",
                getTooltipErrorElement().getText());

        getDeceasedField().click();
        while (!getDeceasedField().getValue().isEmpty()) {
            getDeceasedField().sendKeys(Keys.BACK_SPACE);
        }
        getDeceasedField().sendKeys("YAY!", Keys.ENTER);

        /* no error indicator */
        assertFalse(isElementPresent(By.className("v-errorindicator")));

        assertCommitSuccessful();

        /* commit last name and new deceased status */
        showBeanValues();
        assertEquals(
                "4. Person [firstName=John, lastName=Dover, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=true, salary=null, salaryDouble=null, rent=null]",
                getLogRow(0));
    }

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        // this test also works on IEs, but Firefox has problems with tooltips
        return getBrowsersExcludingFirefox();
    }

}