* {{> fillField }}
(field, value, context = null)
| 1585 | * {{> fillField }} |
| 1586 | */ |
| 1587 | async fillField(field, value, context = null) { |
| 1588 | let els = await findVisibleFields.call(this, field, context) |
| 1589 | if (!els.length) { |
| 1590 | els = await findFields.call(this, field, context) |
| 1591 | } |
| 1592 | assertElementExists(els, field, 'Field') |
| 1593 | const el = selectElement(els, field, this) |
| 1594 | |
| 1595 | if (await fillRichEditor(this, el, value)) { |
| 1596 | highlightActiveElement.call(this, el, await this._getContext()) |
| 1597 | return this._waitForAction() |
| 1598 | } |
| 1599 | |
| 1600 | const tag = await el.getProperty('tagName').then(el => el.jsonValue()) |
| 1601 | const editable = await el.getProperty('contenteditable').then(el => el.jsonValue()) |
| 1602 | if (tag === 'INPUT' || tag === 'TEXTAREA') { |
| 1603 | await this._evaluateHandeInContext(el => (el.value = ''), el) |
| 1604 | } else if (editable) { |
| 1605 | await this._evaluateHandeInContext(el => (el.innerHTML = ''), el) |
| 1606 | } |
| 1607 | |
| 1608 | highlightActiveElement.call(this, el, await this._getContext()) |
| 1609 | await el.type(value.toString(), { delay: this.options.pressKeyDelay }) |
| 1610 | |
| 1611 | return this._waitForAction() |
| 1612 | } |
| 1613 | |
| 1614 | /** |
| 1615 | * {{> clearField }} |
no test coverage detected