MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / sendKeys

Method sendKeys

javascript/selenium-webdriver/lib/webdriver.js:2757–2792  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

2755 * have been typed.
2756 */
2757 async sendKeys(...args) {
2758 let keys = []
2759 ;(await Promise.all(args)).forEach((key) => {
2760 let type = typeof key
2761 if (type === 'number') {
2762 key = String(key)
2763 } else if (type !== 'string') {
2764 throw TypeError('each key must be a number or string; got ' + type)
2765 }
2766
2767 // The W3C protocol requires keys to be specified as an array where
2768 // each element is a single key.
2769 keys.push(...key)
2770 })
2771
2772 if (!this.driver_.fileDetector_) {
2773 return this.execute_(
2774 new command.Command(command.Name.SEND_KEYS_TO_ELEMENT)
2775 .setParameter('text', keys.join(''))
2776 .setParameter('value', keys),
2777 )
2778 }
2779
2780 try {
2781 keys = await this.driver_.fileDetector_.handleFile(this.driver_, keys.join(''))
2782 } catch (ex) {
2783 this.log_.severe('Error trying parse string as a file with file detector; sending keys instead' + ex)
2784 keys = keys.join('')
2785 }
2786
2787 return this.execute_(
2788 new command.Command(command.Name.SEND_KEYS_TO_ELEMENT)
2789 .setParameter('text', keys)
2790 .setParameter('value', keys.split('')),
2791 )
2792 }
2793
2794 /**
2795 * Retrieves the element's tag name.

Callers

nothing calls this directly

Calls 7

execute_Method · 0.95
setParameterMethod · 0.80
joinMethod · 0.80
severeMethod · 0.80
splitMethod · 0.80
forEachMethod · 0.45
handleFileMethod · 0.45

Tested by

no test coverage detected