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.

TabNotVisibleInTheMiddleOfTabsheetTest.java 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.vaadin.tests.components.tabsheet;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertFalse;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.WebElement;
  7. import com.vaadin.testbench.By;
  8. import com.vaadin.testbench.elements.ButtonElement;
  9. import com.vaadin.testbench.elements.TabSheetElement;
  10. import com.vaadin.tests.tb3.MultiBrowserTest;
  11. public class TabNotVisibleInTheMiddleOfTabsheetTest extends MultiBrowserTest {
  12. @Test
  13. public void testFirstTabIsVisibleAfterBeingInvisible() {
  14. openTestURL();
  15. TabSheetElement tabSheet = $(TabSheetElement.class).first();
  16. List<WebElement> captionElements = tabSheet
  17. .findElements(By.className("v-caption"));
  18. int secondPosition = captionElements.get(1).getLocation().getX();
  19. int thirdPosition = captionElements.get(2).getLocation().getX();
  20. assertGreater(
  21. "Third tab should be further than the second tab: "
  22. + thirdPosition + " vs. " + secondPosition,
  23. thirdPosition, secondPosition);
  24. toggleSecondTabVisibility();
  25. assertFalse("TabSheet should not have second tab visible",
  26. captionElements.get(1).isDisplayed());
  27. thirdPosition = captionElements.get(2).getLocation().getX();
  28. assertEquals("Third tab should be where second tab was:",
  29. secondPosition, thirdPosition);
  30. }
  31. private void toggleSecondTabVisibility() {
  32. $(ButtonElement.class).caption("Toggle second tab").first().click();
  33. }
  34. }