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

Method fillField

lib/helper/WebDriver.js:1261–1283  ·  view source on GitHub ↗

* {{> fillField }} * {{ custom }} *

(field, value, context = null)

Source from the content-addressed store, hash-verified

1259 *
1260 */
1261 async fillField(field, value, context = null) {
1262 const res = await findFields.call(this, field, context)
1263 assertElementExists(res, field, 'Field')
1264 const elem = selectElement(res, field, this)
1265 highlightActiveElement.call(this, elem)
1266
1267 if (this.isWeb !== false && await fillRichEditor(this, elem, value)) {
1268 return
1269 }
1270
1271 try {
1272 await elem.clearValue()
1273 } catch (err) {
1274 if (err.message && err.message.includes('invalid element state')) {
1275 await this.executeScript(el => {
1276 el.value = ''
1277 }, elem)
1278 } else {
1279 throw err
1280 }
1281 }
1282 await elem.setValue(value.toString())
1283 }
1284
1285 /**
1286 * {{> appendField }}

Callers

nothing calls this directly

Calls 6

executeScriptMethod · 0.95
selectElementFunction · 0.90
fillRichEditorFunction · 0.90
includesMethod · 0.80
assertElementExistsFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected