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.3KB

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