MCPcopy
hub / github.com/ampproject/amphtml / waitFor

Function waitFor

build-system/tasks/e2e/selenium-webdriver-controller.js:61–75  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

59 * @template T2
60 */
61async 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
77class SeleniumWebDriverController {
78 /**

Callers 1

getWaitFn_Method · 0.70

Calls 2

expectConditionFunction · 0.85
waitMethod · 0.80

Tested by

no test coverage detected