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.

WindowAndUIShortcutsTest.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.vaadin.tests.components.ui;
  2. import static org.junit.Assert.assertTrue;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.Keys;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.interactions.Actions;
  8. import com.vaadin.testbench.elements.ButtonElement;
  9. import com.vaadin.testbench.elements.WindowElement;
  10. import com.vaadin.tests.tb3.SingleBrowserTest;
  11. public class WindowAndUIShortcutsTest extends SingleBrowserTest {
  12. @Test
  13. public void windowShortcutShouldNotReachUI() {
  14. openTestURL();
  15. $(ButtonElement.class).caption("Show page").first().click();
  16. $(ButtonElement.class).caption("Open dialog window").first().click();
  17. $(WindowElement.class).$(ButtonElement.class).first()
  18. .sendKeys(Keys.ESCAPE);
  19. // Window should have been closed
  20. assertTrue($(WindowElement.class).all().isEmpty());
  21. // "Close page" should not have been clicked
  22. assertTrue($(ButtonElement.class).caption("Close page").exists());
  23. }
  24. @Test
  25. public void modalCurtainShouldNotTriggerShortcuts() {
  26. openTestURL();
  27. $(ButtonElement.class).caption("Show page").first().click();
  28. $(ButtonElement.class).caption("Open dialog window").first().click();
  29. WebElement curtain = findElement(
  30. By.className("v-window-modalitycurtain"));
  31. // Click in the curtain next to the window and send escape
  32. new Actions(getDriver()).moveToElement(curtain,
  33. $(WindowElement.class).first().getSize().getWidth() * 2, 0)
  34. .click().sendKeys(Keys.ESCAPE).perform();
  35. // "Close page" should not have been clicked
  36. assertTrue($(ButtonElement.class).caption("Close page").exists());
  37. }
  38. }