How to use the appium-base-driver.errors.NoSuchElementError function in appium-base-driver

To help you get started, we’ve selected a few appium-base-driver 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-xcuitest-driver / lib / commands / find.js View on Github external
// we succeed if we get some elements
      return !_.isEmpty(els);
    });
  } catch (err) {
    if (err.message && err.message.match(/Condition unmet/)) {
      // condition was not met setting res to empty array
      els = [];
    } else {
      throw err;
    }
  }
  if (mult) {
    return els;
  }
  if (_.isEmpty(els)) {
    throw new errors.NoSuchElementError();
  }
  return els;
};
github appium / appium-ios-driver / lib / commands / web.js View on Github external
try {
    await this.implicitWaitForCondition(doFind);
  } catch (err) {
    if (err.message && _.isFunction(err.message.match) && err.message.match(/Condition unmet/)) {
      // condition was not met setting res to empty array
      element = [];
    } else {
      throw err;
    }
  }

  if (many) {
    return element;
  } else {
    if (!element || _.size(element) === 0) {
      throw new errors.NoSuchElementError();
    }
    return element;
  }
};
github appium / appium-ios-driver / lib / commands / find.js View on Github external
try {
    await this.implicitWaitForCondition(doFind);
  } catch (err) {
    if (err.message && err.message.match(/Condition unmet/)) {
      // condition was not met setting res to empty array
      res = [];
    } else {
      throw err;
    }
  }
  if (mult) {
    return res;
  } else {
    if (!res || _.size(res) === 0) {
      throw new errors.NoSuchElementError();
    }
    return res;
  }
};
github appium / appium-android-driver / lib / commands / find.js View on Github external
await this.implicitWaitForCondition(doFind);
  } catch (err) {
    if (err.message && err.message.match(/Condition unmet/)) {
      // only get here if we are looking for multiple elements
      // condition was not met setting res to empty array
      element = [];
    } else {
      throw err;
    }
  }

  if (mult) {
    return element;
  }
  if (_.isEmpty(element)) {
    throw new errors.NoSuchElementError();
  }
  return element;
};
github appium / appium-android-driver / test / unit / commands / find-specs.js View on Github external
it('should throw NoSuchElementError if element does not exist', async function () {
      driver.doFindElementOrEls.throws(new errors.NoSuchElementError());
      await driver.findElOrEls('xpath', '//*[1]', false)
        .should.be.rejectedWith(errors.NoSuchElementError);
    });
    it('should fails if locator strategy is not valid', async function () {
github appium / appium-xcuitest-driver / lib / commands / general.js View on Github external
commands.keys = async function keys (keys) {
  if (!this.isWebContext()) {
    throw new errors.UnknownError('Command should be proxied to WDA');
  }
  let el = util.unwrapElement(await this.active());
  if (_.isEmpty(el)) {
    throw new errors.NoSuchElementError();
  }
  await this.setValue(keys, el);
};
github appium / appium-ios-driver / lib / commands / general.js View on Github external
commands.keys = async function keys (keys) {
  if (this.isWebContext()) {
    let el = await this.active();
    if (_.isUndefined(el.ELEMENT)) {
      throw new errors.NoSuchElementError();
    }
    await this.setValue(keys, el.ELEMENT);
  } else {
    if (_.isArray(keys)) {
      keys = keys.join('');
    }
    if (!_.isString(keys)) {
      keys = keys.toString();
    }
    keys = util.escapeSpecialChars(keys, "'");
    let command = `au.sendKeysToActiveElement('${keys}')`;
    await this.uiAutoClient.sendCommand(command);
  }
};
github appium / appium-ios-driver / lib / commands / find.js View on Github external
if (!_.isEmpty(elements)) {
        res.push(...elements);
      }
    } else {
      let element = await this.uiAutoClient.sendCommand(command);
      if (element) {
        return element;
      }
    }
  }

  if (mult) {
    return res;
  }

  throw new errors.NoSuchElementError();
};