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

Method type

lib/helper/Playwright.js:2256–2272  ·  view source on GitHub ↗

* {{> type }}

(keys, delay = null)

Source from the content-addressed store, hash-verified

2254 * {{> type }}
2255 */
2256 async type(keys, delay = null) {
2257 await checkFocusBeforeType(this)
2258
2259 // Always use page.keyboard.type for any string (including single character and national characters).
2260 if (!Array.isArray(keys)) {
2261 keys = keys.toString()
2262 const typeDelay = typeof delay === 'number' ? delay : this.options.pressKeyDelay
2263 await this.page.keyboard.type(keys, { delay: typeDelay })
2264 return
2265 }
2266
2267 // For array input, treat each as a key press to keep working combinations such as ['Control', 'A'] or ['T', 'e', 's', 't'].
2268 for (const key of keys) {
2269 await this.page.keyboard.press(key)
2270 if (delay) await this.wait(delay / 1000)
2271 }
2272 }
2273
2274 /**
2275 * {{> fillField }}

Callers 3

fillFieldMethod · 0.45
appendFieldMethod · 0.45
targetCreatedHandlerFunction · 0.45

Calls 3

waitMethod · 0.95
checkFocusBeforeTypeFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected