Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

HasValueRequiredIndicatorTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components;
  17. import static org.junit.Assert.assertFalse;
  18. import static org.junit.Assert.assertTrue;
  19. import java.util.List;
  20. import org.junit.Test;
  21. import org.openqa.selenium.By;
  22. import org.openqa.selenium.Point;
  23. import org.openqa.selenium.WebElement;
  24. import com.vaadin.tests.tb3.MultiBrowserTest;
  25. /**
  26. * @author Vaadin Ltd
  27. *
  28. */
  29. public abstract class HasValueRequiredIndicatorTest extends MultiBrowserTest {
  30. @Test
  31. public void requiredIndicatorVisible() {
  32. openTestURL();
  33. List<WebElement> layouts = findElements(By.className("vaadin-layout"));
  34. assertFalse(layouts.isEmpty());
  35. layouts.stream().forEach(this::checkRequiredIndicator);
  36. }
  37. protected void checkRequiredIndicator(WebElement layout) {
  38. WebElement caption = layout.findElement(By.className("v-caption"));
  39. assertTrue(caption.isDisplayed());
  40. WebElement indicator = caption
  41. .findElement(By.className("v-required-field-indicator"));
  42. assertTrue(indicator.isDisplayed());
  43. Point layoutLocation = layout.getLocation();
  44. Point indicatorLocation = indicator.getLocation();
  45. assertTrue("Indicator x-axis location is not inside layout",
  46. indicatorLocation.getX() >= layoutLocation.getX());
  47. assertTrue("Indicator y-axis location is not inside layout",
  48. indicatorLocation.getY() >= layoutLocation.getY());
  49. }
  50. }