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.

CheckboxLabelInputElementTest.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.vaadin.tests.components.checkbox;
  2. import org.junit.Test;
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebElement;
  5. import com.vaadin.testbench.elements.ButtonElement;
  6. import com.vaadin.testbench.elements.CheckBoxElement;
  7. import com.vaadin.tests.tb3.MultiBrowserTest;
  8. import static org.junit.Assert.assertEquals;
  9. import static org.junit.Assert.assertTrue;
  10. public class CheckboxLabelInputElementTest extends MultiBrowserTest {
  11. @Test
  12. public void contextClickCheckboxAndText() {
  13. openTestURL();
  14. CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first();
  15. WebElement labelElem = checkBoxElement.findElement(By.tagName("label"));
  16. WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
  17. assertEquals("my-label-class", labelElem.getAttribute("class"));
  18. assertEquals("my-input-class", inputElem.getAttribute("class"));
  19. assertTrue(
  20. "The Checkbox Widget should not contain the classes that are "
  21. + "defined as style names for the input or label.",
  22. !checkBoxElement.getAttribute("class")
  23. .contains("my-label-class")
  24. && !checkBoxElement.getAttribute("class")
  25. .contains("my-input-class"));
  26. $(ButtonElement.class).caption("add-style").first().click();
  27. assertEquals("my-label-class later-applied-label-class",
  28. labelElem.getAttribute("class"));
  29. assertEquals("my-input-class later-applied-input-class",
  30. inputElem.getAttribute("class"));
  31. assertTrue(
  32. "The Checkbox Widget should not contain the classes that are "
  33. + "defined as style names for the input or label.",
  34. !checkBoxElement.getAttribute("class")
  35. .contains("later-applied-label-class")
  36. && !checkBoxElement.getAttribute("class")
  37. .contains("later-applied-input-class"));
  38. $(ButtonElement.class).caption("remove-style").first().click();
  39. assertEquals("later-applied-label-class",
  40. labelElem.getAttribute("class"));
  41. assertEquals("later-applied-input-class",
  42. inputElem.getAttribute("class"));
  43. $(ButtonElement.class).caption("remove-style-2").first().click();
  44. assertTrue(labelElem.getAttribute("class").isEmpty());
  45. assertTrue(inputElem.getAttribute("class").isEmpty());
  46. }
  47. }