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.

FocusShortcutsTest.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.vaadin.tests.components;
  2. import org.junit.Assert;
  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.tests.tb3.SingleBrowserTest;
  9. public class FocusShortcutsTest extends SingleBrowserTest {
  10. @Test
  11. public void triggerShortCuts() {
  12. openTestURL();
  13. WebElement body = findElement(By.xpath("//body"));
  14. Actions actions = new Actions(getDriver());
  15. actions.keyDown(body, Keys.LEFT_ALT).sendKeys("a").keyUp(Keys.LEFT_ALT)
  16. .build().perform();
  17. Assert.assertEquals("1. Alt+A", getLogRow(0));
  18. body.click();
  19. actions = new Actions(getDriver());
  20. actions.keyDown(body, Keys.LEFT_ALT).sendKeys("n").keyUp(Keys.LEFT_ALT)
  21. .build().perform();
  22. Assert.assertEquals("2. Alt+N", getLogRow(0));
  23. body.click();
  24. actions = new Actions(getDriver());
  25. actions.keyDown(body, Keys.LEFT_CONTROL).keyDown(body, Keys.LEFT_SHIFT)
  26. .sendKeys("d").keyUp(Keys.LEFT_CONTROL).keyUp(Keys.LEFT_SHIFT)
  27. .build().perform();
  28. Assert.assertEquals("3. Ctrl+Shift+D", getLogRow(0));
  29. }
  30. }