* Make the test runner wait until the value returned by the valueFn matches * the given condition. * @param {!WebDriver} driver * @param {function(): !Promise } valueFn * @param {function(T2): ?T1} condition * @param {function(T1): T2} opt_mutate * @return {!Promise<?T2>} * @template T1 *
(driver, valueFn, condition, opt_mutate)
| 59 | * @template T2 |
| 60 | */ |
| 61 | async function waitFor(driver, valueFn, condition, opt_mutate) { |
| 62 | const conditionValue = (value) => { |
| 63 | // Box the value in an object, so values that are present but falsy |
| 64 | // (like "") do not cause driver.wait to continue waiting. |
| 65 | return Boolean(condition(value)); |
| 66 | }; |
| 67 | |
| 68 | /* TODO: fix incorrect typing. */ |
| 69 | /** @type {any} */ |
| 70 | const result = await driver.wait( |
| 71 | expectCondition(valueFn, conditionValue, opt_mutate) |
| 72 | ); |
| 73 | |
| 74 | return result; |
| 75 | } |
| 76 | |
| 77 | class SeleniumWebDriverController { |
| 78 | /** |
no test coverage detected