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.

DateTimeFieldPopupTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.tests.components.datefield;
  2. import org.junit.Test;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.support.ui.ExpectedCondition;
  6. import org.openqa.selenium.support.ui.ExpectedConditions;
  7. import com.vaadin.testbench.By;
  8. import com.vaadin.testbench.elements.DateTimeFieldElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class DateTimeFieldPopupTest extends MultiBrowserTest {
  11. @Test
  12. public void testOpenCloseOpen_popupShouldBeOpen() throws Exception {
  13. openTestURL();
  14. WebElement toggleButton = $(DateTimeFieldElement.class).first()
  15. .findElement(By.className("v-datefield-button"));
  16. toggleButton.click();
  17. assertThatPopupIsVisible();
  18. toggleButton.click();
  19. assertThatPopupIsInvisible();
  20. // We should be able to immediately open the popup from the popup after
  21. // clicking the button to close it. (#8446)
  22. toggleButton.click();
  23. assertThatPopupIsVisible();
  24. }
  25. private void assertThatPopupIsVisible() {
  26. waitUntil(ExpectedConditions.visibilityOfElementLocated(
  27. org.openqa.selenium.By.className("v-datefield-popup")));
  28. }
  29. private void assertThatPopupIsInvisible() {
  30. // ExpectedConditions.invisibilityOfElementLocated doesn't work
  31. // with PhantomJS when running with a hub:
  32. // https://code.google.com/p/selenium/issues/detail?id=5000
  33. // so we need to make our own.
  34. waitUntil(new ExpectedCondition<Boolean>() {
  35. @Override
  36. public Boolean apply(WebDriver input) {
  37. try {
  38. return !(findElement(org.openqa.selenium.By
  39. .className("v-datefield-popup")).isDisplayed());
  40. } catch (Exception e) {
  41. return true;
  42. }
  43. }
  44. @Override
  45. public String toString() {
  46. // Timed out after 10 seconds waiting for ...
  47. return "popup to not be visible";
  48. }
  49. });
  50. }
  51. }