blob: dd47e2c061611c230ddea2e087d05a3f213a42b1 (
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
|
package com.vaadin.tests.components.datefield;
import static com.vaadin.tests.components.datefield.DateFieldClose.DATEFIELD_ID;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class DateFieldCloseTest extends MultiBrowserTest {
private WebElement dateField;
@Test
public void closeByClickingCalendarButton() throws Exception {
openTestURL();
dateField = driver.findElement(By.id(DATEFIELD_ID));
clickButton();
checkForCalendarHeader(true);
closePopup();
checkForCalendarHeader(false);
}
private void checkForCalendarHeader(boolean headerShouldExist) {
boolean headerExists = isElementPresent(
By.className("v-datefield-calendarpanel-header"));
if (headerShouldExist) {
assertTrue("The calendar should be visible", headerExists);
} else {
assertFalse("The calendar should not be visible", headerExists);
}
}
private void clickButton() {
WebElement dateFieldButton = dateField
.findElement(By.className("v-datefield-button"));
testBenchElement(dateFieldButton).click(5, 5);
}
private void closePopup() {
WebElement dateFieldButton = dateField
.findElement(By.className("v-datefield-button"));
// To work reliably with IE, need to click and hold instead of just
// clicking the button.
Actions actions = new Actions(driver);
actions.clickAndHold(dateFieldButton).perform();
}
}
|