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.

DateTimeFieldFastForwardTest.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.vaadin.tests.components.datefield;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertFalse;
  4. import org.junit.Test;
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.interactions.Actions;
  8. import com.vaadin.testbench.elements.VerticalLayoutElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class DateTimeFieldFastForwardTest extends MultiBrowserTest {
  11. @Test
  12. public void testFastForwardOnRightMouseClick() throws Exception {
  13. openTestURL();
  14. String firstMonth = getSelectedMonth();
  15. WebElement nextMonthButton = driver
  16. .findElement(By.className("v-button-nextmonth"));
  17. // Click and hold left mouse button to start fast forwarding.
  18. new Actions(driver).clickAndHold(nextMonthButton).perform();
  19. sleep(1000);
  20. // Right click and release the left button.
  21. new Actions(driver).contextClick(nextMonthButton)
  22. .release(nextMonthButton).perform();
  23. // Now the fast forwarding should be ended, get the expected month.
  24. String expectedMonth = getSelectedMonth();
  25. // Make browser context menu disappear, since it will crash IE
  26. $(VerticalLayoutElement.class).first().click();
  27. assertFalse("Month did not change during fast forward",
  28. firstMonth.equals(expectedMonth));
  29. // Wait for a while.
  30. Thread.sleep(1000);
  31. // Verify that we didn't fast forward any further after the left button
  32. // was released.
  33. String actualMonth = getSelectedMonth();
  34. assertEquals(expectedMonth, actualMonth);
  35. }
  36. private String getSelectedMonth() {
  37. return driver
  38. .findElement(
  39. By.className("v-inline-datefield-calendarpanel-month"))
  40. .getText();
  41. }
  42. }