blob: e826cae2a11a50ea280e6f14c04220f159954199 (
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
|
package com.vaadin.tests.components.datefield;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* @author Vaadin Ltd
*/
public class DateTimeFieldIsValidTest extends MultiBrowserTest {
@Test
public void testInvalidText() throws Exception {
openTestURL();
waitForElementVisible(By.id("Log"));
waitForElementVisible(By.className("v-datefield"));
WebElement dateTextbox = $(AbstractDateFieldElement.class).first()
.findElement(By.className("v-textfield"));
ButtonElement button = $(ButtonElement.class).first();
dateTextbox.sendKeys("01/01/01 1.12", Keys.TAB);
assertLogText("1. valueChange: value: 01/01/01 1.12, is valid: true");
button.click();
assertLogText("2. buttonClick: value: 01/01/01 1.12, is valid: true");
dateTextbox.sendKeys("lala", Keys.TAB);
assertLogText("3. valueChange: value: null, is valid: false");
button.click();
assertLogText("4. buttonClick: value: null, is valid: false");
dateTextbox.clear();
dateTextbox.sendKeys("02/02/02 2.34", Keys.TAB);
assertLogText("5. valueChange: value: 02/02/02 2.34, is valid: true");
button.click();
assertLogText("6. buttonClick: value: 02/02/02 2.34, is valid: true");
}
private void assertLogText(String expected) throws Exception {
String text = findElement(By.vaadin("PID_SLog_row_0")).getText();
assertTrue("Expected '" + expected + "' found '" + text + "'",
text.equals(expected));
}
}
|