* {{> waitForValue }}
(field, value, sec)
| 3214 | * {{> waitForValue }} |
| 3215 | */ |
| 3216 | async waitForValue(field, value, sec) { |
| 3217 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 3218 | const locator = new Locator(field, 'css') |
| 3219 | const matcher = await this.context |
| 3220 | let waiter |
| 3221 | const context = await this._getContext() |
| 3222 | if (!locator.isXPath()) { |
| 3223 | const valueFn = function ([locator, value]) { |
| 3224 | return Array.from(document.querySelectorAll(locator)).filter(el => (el.value || '').indexOf(value) !== -1).length > 0 |
| 3225 | } |
| 3226 | waiter = context.waitForFunction(valueFn, [locator.value, value], { timeout: waitTimeout }) |
| 3227 | } else { |
| 3228 | const valueFn = function ([locator, $XPath, value]) { |
| 3229 | eval($XPath) |
| 3230 | return $XPath(null, locator).filter(el => (el.value || '').indexOf(value) !== -1).length > 0 |
| 3231 | } |
| 3232 | waiter = context.waitForFunction(valueFn, [locator.value, $XPath.toString(), value], { |
| 3233 | timeout: waitTimeout, |
| 3234 | }) |
| 3235 | } |
| 3236 | return waiter.catch(err => { |
| 3237 | const loc = locator.toString() |
| 3238 | throw new Error(`element (${loc}) is not in DOM or there is no element(${loc}) with value "${value}" after ${waitTimeout / 1000} sec\n${err.message}`) |
| 3239 | }) |
| 3240 | } |
| 3241 | |
| 3242 | /** |
| 3243 | * {{> waitNumberOfVisibleElements }} |
nothing calls this directly
no test coverage detected