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.

AccordionRemoveTabTest.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.vaadin.tests.components.accordion;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import org.junit.Test;
  5. import org.openqa.selenium.WebElement;
  6. import com.vaadin.testbench.By;
  7. import com.vaadin.tests.tb3.MultiBrowserTest;
  8. /**
  9. * Test for Accordion: tabs should stay selectable after remove tab.
  10. *
  11. * @since 7.2
  12. * @author Vaadin Ltd
  13. */
  14. public class AccordionRemoveTabTest extends MultiBrowserTest {
  15. @Test
  16. public void testRemoveTab() {
  17. openTestURL();
  18. WebElement button = driver.findElement(By.className("v-button"));
  19. button.click();
  20. checkFirstItemHeight("On second tab");
  21. button.click();
  22. checkFirstItemHeight("On third tab");
  23. }
  24. @Test
  25. public void testConsoleErrorOnSwitch() {
  26. setDebug(true);
  27. openTestURL();
  28. WebElement firstItem = driver
  29. .findElement(By.className("v-accordion-item-first"));
  30. WebElement caption = firstItem
  31. .findElement(By.className("v-accordion-item-caption"));
  32. caption.click();
  33. assertEquals("Errors present in console", 0,
  34. findElements(By.className("SEVERE")).size());
  35. }
  36. private void checkFirstItemHeight(String text) {
  37. WebElement firstItem = driver
  38. .findElement(By.className("v-accordion-item-first"));
  39. WebElement label = firstItem.findElement(By.className("v-label"));
  40. assertEquals("Unexpected text in first item", text, label.getText());
  41. int height = firstItem.getSize().getHeight();
  42. WebElement accordion = driver.findElement(By.className("v-accordion"));
  43. assertTrue("First item in accordion has unexpected height",
  44. height > accordion.getSize().getHeight() / 2);
  45. }
  46. }