[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { TestKey } from '@angular/cdk/testing';
|
---|
| 9 | import * as webdriver from 'selenium-webdriver';
|
---|
| 10 | /**
|
---|
| 11 | * Maps the `TestKey` constants to WebDriver's `webdriver.Key` constants.
|
---|
| 12 | * See https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/webdriver/key.js#L29
|
---|
| 13 | */
|
---|
| 14 | export const seleniumWebDriverKeyMap = {
|
---|
| 15 | [TestKey.BACKSPACE]: webdriver.Key.BACK_SPACE,
|
---|
| 16 | [TestKey.TAB]: webdriver.Key.TAB,
|
---|
| 17 | [TestKey.ENTER]: webdriver.Key.ENTER,
|
---|
| 18 | [TestKey.SHIFT]: webdriver.Key.SHIFT,
|
---|
| 19 | [TestKey.CONTROL]: webdriver.Key.CONTROL,
|
---|
| 20 | [TestKey.ALT]: webdriver.Key.ALT,
|
---|
| 21 | [TestKey.ESCAPE]: webdriver.Key.ESCAPE,
|
---|
| 22 | [TestKey.PAGE_UP]: webdriver.Key.PAGE_UP,
|
---|
| 23 | [TestKey.PAGE_DOWN]: webdriver.Key.PAGE_DOWN,
|
---|
| 24 | [TestKey.END]: webdriver.Key.END,
|
---|
| 25 | [TestKey.HOME]: webdriver.Key.HOME,
|
---|
| 26 | [TestKey.LEFT_ARROW]: webdriver.Key.ARROW_LEFT,
|
---|
| 27 | [TestKey.UP_ARROW]: webdriver.Key.ARROW_UP,
|
---|
| 28 | [TestKey.RIGHT_ARROW]: webdriver.Key.ARROW_RIGHT,
|
---|
| 29 | [TestKey.DOWN_ARROW]: webdriver.Key.ARROW_DOWN,
|
---|
| 30 | [TestKey.INSERT]: webdriver.Key.INSERT,
|
---|
| 31 | [TestKey.DELETE]: webdriver.Key.DELETE,
|
---|
| 32 | [TestKey.F1]: webdriver.Key.F1,
|
---|
| 33 | [TestKey.F2]: webdriver.Key.F2,
|
---|
| 34 | [TestKey.F3]: webdriver.Key.F3,
|
---|
| 35 | [TestKey.F4]: webdriver.Key.F4,
|
---|
| 36 | [TestKey.F5]: webdriver.Key.F5,
|
---|
| 37 | [TestKey.F6]: webdriver.Key.F6,
|
---|
| 38 | [TestKey.F7]: webdriver.Key.F7,
|
---|
| 39 | [TestKey.F8]: webdriver.Key.F8,
|
---|
| 40 | [TestKey.F9]: webdriver.Key.F9,
|
---|
| 41 | [TestKey.F10]: webdriver.Key.F10,
|
---|
| 42 | [TestKey.F11]: webdriver.Key.F11,
|
---|
| 43 | [TestKey.F12]: webdriver.Key.F12,
|
---|
| 44 | [TestKey.META]: webdriver.Key.META
|
---|
| 45 | };
|
---|
| 46 | /** Gets a list of WebDriver `Key`s for the given `ModifierKeys`. */
|
---|
| 47 | export function getSeleniumWebDriverModifierKeys(modifiers) {
|
---|
| 48 | const result = [];
|
---|
| 49 | if (modifiers.control) {
|
---|
| 50 | result.push(webdriver.Key.CONTROL);
|
---|
| 51 | }
|
---|
| 52 | if (modifiers.alt) {
|
---|
| 53 | result.push(webdriver.Key.ALT);
|
---|
| 54 | }
|
---|
| 55 | if (modifiers.shift) {
|
---|
| 56 | result.push(webdriver.Key.SHIFT);
|
---|
| 57 | }
|
---|
| 58 | if (modifiers.meta) {
|
---|
| 59 | result.push(webdriver.Key.META);
|
---|
| 60 | }
|
---|
| 61 | return result;
|
---|
| 62 | }
|
---|
| 63 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZW5pdW0td2ViZHJpdmVyLWtleXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3Rlc3Rpbmcvc2VsZW5pdW0td2ViZHJpdmVyL3NlbGVuaXVtLXdlYmRyaXZlci1rZXlz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