waitFor = async (element, time, options = {}) => {
  validate();
  let timeout;
  let message;
  if (isObject(time)) {
    timeout = defaultConfig.retryTimeout;
    message = time.message;
  } else {
    timeout = time || defaultConfig.retryTimeout;
    message = options.message;
  }
  if (!element || Number.isFinite(element)) {
    return wait(element);
    // biome-ignore lint/style/noUselessElse: Don't break the chain
  } else if (isString(element)) {
    const foundElements = await match(element).elements(
      undefined,
      defaultConfig.retryInterval,
      timeout,
    );
    if (!foundElements.length) {
      throw new Error(
        `Waiting Failed: Element '${element}' not found within ${timeout} ms`,
      );
    }
  } else if (isSelector(element)) {
    const foundElements = await element.elements(
      defaultConfig.retryInterval,
      timeout,
    );
    if (!foundElements.length) {
      throw new Error(
        `Waiting Failed: Element '${element}' not found within ${timeout} ms`,
      );
    }
  } else {
    await waitUntil(element, defaultConfig.retryInterval, timeout, message);
  }
}
This function is used to wait for number of milliseconds given or a given element or a given condition.

@example
waitFor(5000)
@example
waitFor("1 item in cart")
@example
waitFor("Order Created", 2000)
@example
waitFor(async () => !(await $("loading-text").exists()))

@param {string} element - Element/condition to wait for
@param {number|time} time - Time to wait. default to 10s
@param { options.message } - Custom message
@return {promise}