You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PopupClosingWithEscTest.java 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.vaadin.tests.components.datefield;
  2. import static org.junit.Assert.assertFalse;
  3. import static org.junit.Assert.assertTrue;
  4. import org.junit.Test;
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.Keys;
  7. import com.vaadin.tests.tb3.MultiBrowserTest;
  8. public class PopupClosingWithEscTest extends MultiBrowserTest {
  9. @Test
  10. public void testPopupClosingDayResolution() {
  11. testPopupClosing("day");
  12. }
  13. @Test
  14. public void testPopupClosingMonthResolution() {
  15. testPopupClosing("month");
  16. }
  17. @Test
  18. public void testPopupClosingYearResolution() {
  19. testPopupClosing("year");
  20. }
  21. private void testPopupClosing(String dateFieldId) {
  22. openTestURL();
  23. openPopup(dateFieldId);
  24. assertTrue(isPopupVisible());
  25. sendEscToCalendarPanel();
  26. assertFalse(isPopupVisible());
  27. }
  28. private void openPopup(String dateFieldId) {
  29. driver.findElement(
  30. vaadinLocator("PID_S" + dateFieldId + "#popupButton")).click();
  31. }
  32. private boolean isPopupVisible() {
  33. return !(driver.findElements(By.cssSelector(".v-datefield-popup"))
  34. .isEmpty());
  35. }
  36. private void sendEscToCalendarPanel() {
  37. driver.findElement(By.cssSelector(".v-datefield-calendarpanel"))
  38. .sendKeys(Keys.ESCAPE);
  39. }
  40. }