/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { TestKey } from '@angular/cdk/testing'; import * as webdriver from 'selenium-webdriver'; /** * Maps the `TestKey` constants to WebDriver's `webdriver.Key` constants. * See https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/webdriver/key.js#L29 */ export const seleniumWebDriverKeyMap = { [TestKey.BACKSPACE]: webdriver.Key.BACK_SPACE, [TestKey.TAB]: webdriver.Key.TAB, [TestKey.ENTER]: webdriver.Key.ENTER, [TestKey.SHIFT]: webdriver.Key.SHIFT, [TestKey.CONTROL]: webdriver.Key.CONTROL, [TestKey.ALT]: webdriver.Key.ALT, [TestKey.ESCAPE]: webdriver.Key.ESCAPE, [TestKey.PAGE_UP]: webdriver.Key.PAGE_UP, [TestKey.PAGE_DOWN]: webdriver.Key.PAGE_DOWN, [TestKey.END]: webdriver.Key.END, [TestKey.HOME]: webdriver.Key.HOME, [TestKey.LEFT_ARROW]: webdriver.Key.ARROW_LEFT, [TestKey.UP_ARROW]: webdriver.Key.ARROW_UP, [TestKey.RIGHT_ARROW]: webdriver.Key.ARROW_RIGHT, [TestKey.DOWN_ARROW]: webdriver.Key.ARROW_DOWN, [TestKey.INSERT]: webdriver.Key.INSERT, [TestKey.DELETE]: webdriver.Key.DELETE, [TestKey.F1]: webdriver.Key.F1, [TestKey.F2]: webdriver.Key.F2, [TestKey.F3]: webdriver.Key.F3, [TestKey.F4]: webdriver.Key.F4, [TestKey.F5]: webdriver.Key.F5, [TestKey.F6]: webdriver.Key.F6, [TestKey.F7]: webdriver.Key.F7, [TestKey.F8]: webdriver.Key.F8, [TestKey.F9]: webdriver.Key.F9, [TestKey.F10]: webdriver.Key.F10, [TestKey.F11]: webdriver.Key.F11, [TestKey.F12]: webdriver.Key.F12, [TestKey.META]: webdriver.Key.META, [TestKey.COMMA]: ',', }; /** Gets a list of WebDriver `Key`s for the given `ModifierKeys`. */ export function getSeleniumWebDriverModifierKeys(modifiers) { const result = []; if (modifiers.control) { result.push(webdriver.Key.CONTROL); } if (modifiers.alt) { result.push(webdriver.Key.ALT); } if (modifiers.shift) { result.push(webdriver.Key.SHIFT); } if (modifiers.meta) { result.push(webdriver.Key.META); } return result; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZW5pdW0td2ViZHJpdmVyLWtleXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3Rlc3Rpbmcvc2VsZW5pdW0td2ViZHJpdmVyL3NlbGVuaXVtLXdlYmRyaXZlci1rZXlzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBZSxPQUFPLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssU0FBUyxNQUFNLG9CQUFvQixDQUFDO0FBRWhEOzs7R0FHRztBQUNILE1BQU0sQ0FBQyxNQUFNLHVCQUF1QixHQUFHO0lBQ3JDLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsVUFBVTtJQUM3QyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxTQUFTLENBQUMsR0FBRyxDQUFDLEdBQUc7SUFDaEMsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLEVBQUUsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLO0lBQ3BDLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsS0FBSztJQUNwQyxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRSxTQUFTLENBQUMsR0FBRyxDQUFDLE9BQU87SUFDeEMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUU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