MCPcopy
hub / github.com/codeceptjs/CodeceptJS / typeText

Method typeText

lib/element/WebElement.js:306–324  ·  view source on GitHub ↗

* Type characters via the page/browser keyboard into the focused element. * Unlike `type()`, this does not call `.fill()`/`.setValue()`, so it works * with contenteditable nodes, iframe bodies, and editor-owned hidden textareas. * @param {string} text Text to send * @param {Object} [opti

(text, options = {})

Source from the content-addressed store, hash-verified

304 * @returns {Promise<void>}
305 */
306 async typeText(text, options = {}) {
307 const s = String(text)
308 switch (this.helperType) {
309 case 'playwright':
310 case 'puppeteer':
311 return this.helper.page.keyboard.type(s, options)
312 case 'webdriver': {
313 const ENTER = '\uE007'
314 const parts = s.split('\n')
315 for (let i = 0; i < parts.length; i++) {
316 if (parts[i]) await this.helper.browser.keys(parts[i])
317 if (i < parts.length - 1) await this.helper.browser.keys(ENTER)
318 }
319 return
320 }
321 default:
322 throw new Error(`Unsupported helper type: ${this.helperType}`)
323 }
324 }
325
326 /**
327 * Select all content in the focused field and delete it via keyboard input.

Callers 1

fillRichEditorFunction · 0.80

Calls 1

typeMethod · 0.45

Tested by

no test coverage detected