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.

TimePopupSelectionTest.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.vaadin.tests.components.datefield;
  2. import static org.junit.Assert.assertEquals;
  3. import java.util.List;
  4. import org.junit.Test;
  5. import org.openqa.selenium.Keys;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.support.ui.Select;
  8. import com.vaadin.testbench.By;
  9. import com.vaadin.testbench.elements.DateTimeFieldElement;
  10. import com.vaadin.tests.tb3.MultiBrowserTest;
  11. /**
  12. * @author Vaadin Ltd
  13. *
  14. */
  15. public class TimePopupSelectionTest extends MultiBrowserTest {
  16. @Test
  17. public void selectDateAndTimeFromPopup() {
  18. openTestURL();
  19. DateTimeFieldElement field = $(DateTimeFieldElement.class).first();
  20. assertEquals("1/13/17 01:00:00 AM", field.getValue());
  21. field.openPopup();
  22. List<WebElement> timeSelects = findElement(
  23. By.className("v-datefield-calendarpanel-time"))
  24. .findElements(By.tagName("select"));
  25. new Select(timeSelects.get(0)).selectByValue("09");
  26. assertEquals("1/13/17 09:00:00 AM", field.getValue());
  27. new Select(timeSelects.get(1)).selectByValue("35");
  28. assertEquals("1/13/17 09:35:00 AM", field.getValue());
  29. new Select(timeSelects.get(2)).selectByValue("41");
  30. assertEquals("1/13/17 09:35:41 AM", field.getValue());
  31. closePopup();
  32. waitUntil(driver -> getLogRow(0).equals("1. 13/01/2017 09:35:41"));
  33. }
  34. private void closePopup() {
  35. findElement(By.className("v-datefield-calendarpanel"))
  36. .sendKeys(Keys.ENTER);
  37. }
  38. }