How to use the asyncbox.retryInterval function in asyncbox

To help you get started, we’ve selected a few asyncbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-android-driver / test / functional / commands / keyboard / keyboard-e2e-specs.js View on Github external
async function ensureUnlocked (driver) {
  // on Travis the device is sometimes not unlocked
  await retryInterval(10, 1000, async function () {
    if (!await driver.isLocked()) {
      return;
    }
    console.log(`\n\nDevice locked. Attempting to unlock`); // eslint-disable-line
    await driver.unlock();
    // trigger another iteration
    throw new Error(`The device is locked.`);
  });
}
github appium / appium-xcuitest-driver / test / functional / basic / element-e2e-specs.js View on Github external
it('should type a url in the text field', async function () {
          // in Travis this sometimes gets the wrong text
          let retries = process.env.CI ? 5 : 1;
          await retryInterval(retries, 100, async () => {
            let el = await driver.elementByClassName('XCUIElementTypeTextField');
            await el.clear();
            await el.type(text3);

            let text = await el.text();
            text.should.eql(text3);
          });
        });
        it('should be able to type into two text fields', async function () {
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
async tailLogsUntil (bootedIndicator, timeoutMs) {
    let simLog = path.resolve(this.getLogDir(), 'system.log');

    // we need to make sure log file exists before we can tail it
    await retryInterval(200, 200, async () => {
      let exists = await fs.exists(simLog);
      if (!exists) {
        throw new Error(`Could not find Simulator log: '${simLog}'`);
      }
    });

    log.info(`Simulator log at '${simLog}'`);
    log.info(`Tailing simulator logs until we encounter the string "${bootedIndicator}"`);
    log.info(`We will time out after ${timeoutMs}ms`);
    try {
      await tailUntil(simLog, bootedIndicator, timeoutMs);
    } catch (err) {
      log.debug('Simulator startup timed out. Continuing anyway.');
    }
  }
github appium / appium-ios-driver / lib / commands / context.js View on Github external
let navigate = async () => {
    let oldImpWait = this.implicitWaitMs;
    this.implicitWaitMs = 7000;

    // find the url bar, and tap on it. retry to make sure we don't try
    // too soon while the view is still loading
    let el = await retryInterval(3, 1000, async () => {
      return await this.findElement('accessibility id', 'URL');
    });
    this.implicitWaitMs = oldImpWait;

    try {
      await this.nativeTap(el.ELEMENT);
    } catch (err) {
      if (_.includes(err.message, 'could not be tapped')) {
        if (tries++ >= MAX_TRIES) throw err; // eslint-disable-line curly

        // generally this means that Safari is in page viewing mode
        // so try to open a new page and then redo the navigation
        await openNewPage();
        return await navigate();
      } else {
        throw err;
github appium / appium-android-driver / lib / commands / performance.js View on Github external
helpers.getCPUInfo = async function getCPUInfo (packageName, dataReadTimeout = 2) {
  // TODO: figure out why this is
  // sometimes, the function of 'adb.shell' fails. when I tested this function on the target of 'Galaxy Note5',
  // adb.shell(dumpsys cpuinfo) returns cpu datas for other application packages, but I can't find the data for packageName.
  // It usually fails 30 times and success for the next time,
  // Since then, he has continued to succeed.
  return await retryInterval(dataReadTimeout, RETRY_PAUSE, async () => {
    const cmd = ['dumpsys', 'cpuinfo', '|', 'grep', `'${packageName}'`];
    const data = await this.adb.shell(cmd);
    if (_.isEmpty(data)) {
      throw new Error('No data from dumpsys');
    }
    // `data` will be something like
    //    +0% 2209/io.appium.android.apis: 0.1% user + 0.2% kernel
    const userMatch = /([\d.]+)%\s+user/.exec(data);
    const kernelMatch = /([\d.]+)%\s+kernel/.exec(data);
    if (!userMatch || !kernelMatch) {
      throw new Error(`Unable to parse cpu data: '${data}'`);
    }
    return [_.clone(CPU_KEYS), [userMatch[1], kernelMatch[1]]];
  });
};
github appium / appium-uiautomator2-driver / test / functional / commands / keyboard / keyboard-e2e-specs.js View on Github external
async function runTextEditTest (driver, testText, keys = false) {
  let el = await getElement(driver, EDITTEXT_CLASS);
  await el.clear();
  await el.click();

  if (keys) {
    await driver.keys([testText]);
  } else {
    await el.sendKeys(testText);
  }

  await retryInterval(process.env.TESTOBJECT_E2E_TESTS ? 100 : 10, 1000, async () => {
    let text = await el.text();
    deSamsungify(text).should.be.equal(testText);
  });

  return el;
}
github appium / appium-xcuitest-driver / test / functional / driver / driver-e2e-specs.js View on Github external
beforeEach(async function () {
        await retryInterval(5, 1000, async () => {
          await killAllSimulators();
        });
      });
github appium / appium-xcuitest-driver / test / functional / web / safari-nativewebtap-e2e-specs.js View on Github external
async function loadPage (driver, url) {
      await retryInterval(5, 1000, async function () {
        await openPage(driver, url);
        const title = await spinTitle(driver);
        title.should.not.include('Cannot Open Page');
      });
    }
github appium / appium-uiautomator2-driver / test / functional / commands / general / element-e2e-specs.js View on Github external
before(async function () {
    driver = await initSession(Object.assign({}, APIDEMOS_CAPS, {appActivity: textFieldsActivity}));
    el = await retryInterval(5, 1000, async function () {
      const els = await driver.elementsByClassName('android.widget.EditText');
      els.should.have.length.at.least(1);
      return _.last(els);
    });
  });
  after(async function () {

asyncbox

A collection of small async/await utilities

Apache-2.0
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis