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.

HasValueRequiredIndicatorTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.vaadin.tests.components;
  2. import static org.junit.Assert.assertFalse;
  3. import static org.junit.Assert.assertTrue;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.Point;
  8. import org.openqa.selenium.WebElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. /**
  11. * @author Vaadin Ltd
  12. *
  13. */
  14. public abstract class HasValueRequiredIndicatorTest extends MultiBrowserTest {
  15. @Test
  16. public void requiredIndicatorVisible() {
  17. openTestURL();
  18. List<WebElement> layouts = findElements(By.className("vaadin-layout"));
  19. assertFalse(layouts.isEmpty());
  20. layouts.stream().forEach(this::checkRequiredIndicator);
  21. }
  22. protected void checkRequiredIndicator(WebElement layout) {
  23. WebElement caption = layout.findElement(By.className("v-caption"));
  24. assertTrue(caption.isDisplayed());
  25. WebElement indicator = caption
  26. .findElement(By.className("v-required-field-indicator"));
  27. assertTrue(indicator.isDisplayed());
  28. Point layoutLocation = layout.getLocation();
  29. Point indicatorLocation = indicator.getLocation();
  30. assertTrue("Indicator x-axis location is not inside layout",
  31. indicatorLocation.getX() >= layoutLocation.getX());
  32. assertTrue("Indicator y-axis location is not inside layout",
  33. indicatorLocation.getY() >= layoutLocation.getY());
  34. }
  35. }