@Override public List<Interaction> asInteractions(PointerInput mouse, KeyInput keyboard) { ArrayList<Interaction> interactions = new ArrayList<>(); interactions.addAll(optionallyClickElement(mouse)); interactions.add(keyboard.createKeyDown(key.getCodePoint())); return Collections.unmodifiableList(interactions); } }
@Override public List<Interaction> asInteractions(PointerInput mouse, KeyInput keyboard) { List<Interaction> toReturn = new ArrayList<>(optionallyClickElement(mouse)); toReturn.add(keyboard.createKeyUp(key.getCodePoint())); return Collections.unmodifiableList(toReturn); }
@Test public void testLowLevelKeys() { wait.until(ExpectedConditions.presenceOfElementLocated(loginScreen)).click(); WebElement usernameField = driver.findElement(username); usernameField.click(); KeyInput keyboard = new KeyInput("keyboard"); Sequence sendKeys = new Sequence(keyboard, 0); sendKeys.addAction(keyboard.createKeyDown(Keys.SHIFT.getCodePoint())); sendKeys.addAction(keyboard.createKeyDown("f".codePointAt(0))); sendKeys.addAction(keyboard.createKeyUp("f".codePointAt(0))); sendKeys.addAction(keyboard.createKeyUp(Keys.SHIFT.getCodePoint())); sendKeys.addAction(keyboard.createKeyDown("o".codePointAt(0))); sendKeys.addAction(keyboard.createKeyUp("o".codePointAt(0))); sendKeys.addAction(keyboard.createKeyDown("o".codePointAt(0))); sendKeys.addAction(keyboard.createKeyUp("o".codePointAt(0))); driver.perform(Arrays.asList(sendKeys)); Assert.assertEquals("Foo", usernameField.getText()); }