您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

InitialFocusTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.vaadin.tests.components.window;
  2. import com.vaadin.testbench.elements.ComboBoxElement;
  3. import com.vaadin.tests.tb3.MultiBrowserTest;
  4. import org.junit.Assert;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebElement;
  8. public class InitialFocusTest extends MultiBrowserTest {
  9. /**
  10. * To test an implementation of
  11. * {@code com.google.gwt.user.client.ui.Focusable} which is nameField of
  12. * TextField type
  13. */
  14. @Test
  15. public void window_callingFocusNameField_nameFieldShouldGetFocused() {
  16. openTestURL();
  17. WebElement openWindowButton = findElement(
  18. By.id(InitialFocus.FOCUS_NAME_BUTTON_ID));
  19. openWindowButton.click();
  20. waitForElementPresent(By.id(InitialFocus.NAME_FIELD_ID));
  21. WebElement focusedElement = getFocusedElement();
  22. Assert.assertNotNull(
  23. "Name TextField should have focus while focusedElement is null.",
  24. focusedElement);
  25. String focusedElementId = focusedElement.getAttribute("id");
  26. Assert.assertEquals(
  27. "Name TextField should have focus while " + focusedElementId
  28. + " has focus.",
  29. InitialFocus.NAME_FIELD_ID, focusedElementId);
  30. }
  31. /**
  32. * To test an implementation of {@code com.vaadin.client.Focusable} which is
  33. * genderField of ComboBox type
  34. */
  35. @Test
  36. public void window_callingFocusGenderField_genderFieldShouldGetFocused() {
  37. openTestURL();
  38. WebElement openWindowButton = findElement(
  39. By.id(InitialFocus.FOCUS_GENDER_BUTTON_ID));
  40. openWindowButton.click();
  41. waitForElementPresent(By.id(InitialFocus.GENDER_FIELD_ID));
  42. WebElement focusedElement = getFocusedElement();
  43. Assert.assertNotNull(
  44. "Gender ComboBox should have focus while focusedElement is null.",
  45. focusedElement);
  46. ComboBoxElement genderField = $(ComboBoxElement.class).first();
  47. Assert.assertEquals(
  48. "Gender ComboBox should have focus while another element has focus.",
  49. genderField.getInputField(), focusedElement);
  50. }
  51. }