* Types a key sequence on the DOM element represented by this instance. * * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is * processed in the key sequence, that key state is toggled until one of the * following occurs: * * - The modifier key is encounter
(...args)
| 2881 | * have been typed. |
| 2882 | */ |
| 2883 | async sendKeys(...args) { |
| 2884 | let keys = [] |
| 2885 | ;(await Promise.all(args)).forEach((key) => { |
| 2886 | let type = typeof key |
| 2887 | if (type === 'number') { |
| 2888 | key = String(key) |
| 2889 | } else if (type !== 'string') { |
| 2890 | throw TypeError('each key must be a number or string; got ' + type) |
| 2891 | } |
| 2892 | |
| 2893 | // The W3C protocol requires keys to be specified as an array where |
| 2894 | // each element is a single key. |
| 2895 | keys.push(...key) |
| 2896 | }) |
| 2897 | |
| 2898 | if (!this.driver_.fileDetector_) { |
| 2899 | return this.execute_( |
| 2900 | new command.Command(command.Name.SEND_KEYS_TO_ELEMENT) |
| 2901 | .setParameter('text', keys.join('')) |
| 2902 | .setParameter('value', keys), |
| 2903 | ) |
| 2904 | } |
| 2905 | |
| 2906 | try { |
| 2907 | keys = await this.driver_.fileDetector_.handleFile(this.driver_, keys.join('')) |
| 2908 | } catch (ex) { |
| 2909 | this.log_.severe('Error trying parse string as a file with file detector; sending keys instead' + ex) |
| 2910 | keys = keys.join('') |
| 2911 | } |
| 2912 | |
| 2913 | return this.execute_( |
| 2914 | new command.Command(command.Name.SEND_KEYS_TO_ELEMENT) |
| 2915 | .setParameter('text', keys) |
| 2916 | .setParameter('value', keys.split('')), |
| 2917 | ) |
| 2918 | } |
| 2919 | |
| 2920 | /** |
| 2921 | * Retrieves the element's tag name. |
nothing calls this directly
no test coverage detected