* Inserts a sequence of actions to type the provided key sequence. * For each key, this will record a pair of plain #keyDown keyDown * and plain #keyUp keyUp actions. An implication of this pairing * is that modifier keys (e.g. ./input.Key.SHIFT Key.SHIFT) will * al
(...keys)
| 798 | * @return {!Actions} a self reference. |
| 799 | */ |
| 800 | sendKeys(...keys) { |
| 801 | const { WebElement } = require('./webdriver') |
| 802 | |
| 803 | const actions = [] |
| 804 | if (keys.length > 1 && keys[0] instanceof WebElement) { |
| 805 | this.click(keys[0]) |
| 806 | keys.shift() |
| 807 | } |
| 808 | for (const key of keys) { |
| 809 | if (typeof key === 'string') { |
| 810 | for (const symbol of key) { |
| 811 | actions.push(this.keyboard_.keyDown(symbol), this.keyboard_.keyUp(symbol)) |
| 812 | } |
| 813 | } else { |
| 814 | actions.push(this.keyboard_.keyDown(key), this.keyboard_.keyUp(key)) |
| 815 | } |
| 816 | } |
| 817 | return this.insert(this.keyboard_, ...actions) |
| 818 | } |
| 819 | |
| 820 | /** |
| 821 | * Inserts an action to press a mouse button at the mouse's current location. |